JAVA_LeetCode 3456_Find Special Substring of Length K 풀이 class Solution { public boolean hasSpecialSubstring(String s, int k) { // 문자가 같은경우를 체크하되, 다른 경우 조건에 부합한지 체크한다. int cnt = 1; for(int i = 1; i < s.length(); i++){ if(s.charAt(i - 1) != s.charAt(i) && cnt == k) return true; if(s.charAt(i) !
= s.charAt(i - 1)) cnt = 0; cnt++; } return cnt == k; } } * 출처 https://leetcode.com/problems/find-special-substring-of-length-k...