Day75

강태훈·2026년 4월 17일

nbcamp TIL

목록 보기
75/97

알고리즘 코드카타

Not Boring Movies

select *
from Cinema
where id % 2 = 1
and description != 'boring'
order by rating desc
;

옹알이(2)

class Solution {
    public int solution(String[] babbling) {
        int answer = 0;
        String[] pron = {"aya", "ye", "woo", "ma"};

        int j = 1;
        for (String word : babbling){
            boolean cando = false;
            StringBuilder sb = new StringBuilder(word);

            for (int i = 0; i <= 3; i++) {
                int findIndex = sb.indexOf(pron[i]);
                if (findIndex != -1) {
                    sb.replace(findIndex, findIndex + pron[i].length(), " ");

                    if (sb.toString().contains(pron[i]) && sb.indexOf(pron[i]) != findIndex+1){
                        i--;
                    }

                    if (sb.toString().replace(" ", "").length() == 0){
                        cando = true;
                        break;
                    }
                }
            }
            if (cando){
                answer++;
            }
        }
        return answer;
    }
}

0개의 댓글