https://leetcode.com/problems/counting-words-with-a-given-prefix/

 

주어진 접두어로 단어세기.

 

이번 일일 문제는 너무 간단해서 딱히 쓸 말이 없다

class Solution {
    public int prefixCount(String[] words, String pref) {
        int count = 0;
        
        for(String text : words){
        	// 문자열의 첫머리가 pref와 일치한다면
            if(text.startsWith(pref)){
                count++;
            }
        }
        return count;
    }
}

 

 

'코테 > LeetCode' 카테고리의 다른 글

3223. Minimum Length of String After Operations  (0) 2025.01.13
916. Word Subsets  (0) 2025.01.11
3042. Count Prefix and Suffix Pairs I  (0) 2025.01.08
1408. String Matching in an Array | 배열의 문자열 일치  (1) 2025.01.07
383. Ransom Note  (0) 2025.01.06

+ Recent posts