seunghyun Note
[프로그래머스] - 부분 문자열인지 확인하기 with JAVA 본문
링크 : https://school.programmers.co.kr/learn/courses/30/lessons/181843
문제 풀이
문제를 푸는게 중요하다. 간단하게 못해도 해결할 수 있다는 것이 코테의 매력이고 실력 향상에 좋은거 같다. (라고 합리화 시작)
contains(CharSequence s)
Returns true if and only if this string contains the specified sequence of char values.
Contains를 사용하는 법부터 보자!
public class ContainsTest{
public static void main(String[] args){
String str = "my java test";
System.out.println( str.contains("java") ); // true
System.out.println( str.contains(" my") ); // false
System.out.println( str.contains("JAVA") ); // false
System.out.println( str.contains("java test") ); // true
}
}
해결.!
class Solution {
public int solution(String my_string, String target) {
return my_string.contains(target)? 1: 0;
}
}
728x90
'코딩테스트 > 백준' 카테고리의 다른 글
[프로그래머스] - 크기가 작은 부분 문자열 with JAVA (0) | 2024.01.06 |
---|---|
[프로그래머스] - 같은 숫자는 싫어! (0) | 2024.01.06 |
[프로그래머스] - 예산 with JAVA (1) | 2024.01.06 |
[프로그래머스] - 숫자 문자열과 영단어 with JAVA (0) | 2024.01.06 |
[프로그래머스] - 가장 가까운 같은 글자 with JAVA (0) | 2024.01.06 |