코딩테스트 풀이/JAVA
[LeetCode/Easy] 1967. Number of Strings That Appear as Substrings in Word
무지맘
2023. 1. 9. 00:07
1. Input
1) 문자열 배열 patterns
2) 문자열 word
2. Output
1) patterns의 요소들 중 word의 substring 개수를 반환
3. Constraint
1) 1 <= patterns.length <= 100
2) 1 <= patterns[i].length <= 100
3) 1 <= word.length <= 100
4) patterns의 요소들과 word는 영어 소문자로만 이루어져 있다.
4. Example
Input: patterns = ["a","abc","bc","d"], word = "abc" -> Output: 3
설명: abc의 substring이 될 수 있는 것은 a, abc, bc 3개가 있다.
5. Code
1) 첫 코드(2022/06/14)
int count = 0;
for(int i=0 ; i<patterns.length ; i++){
if(word.contains(patterns[i]))
count++;
}
return count;