(int[] colors, int k)
| 1 | class Solution { |
| 2 | public int numberOfAlternatingGroups(int[] colors, int k) { |
| 3 | int res=0; |
| 4 | int left=0; |
| 5 | int n = colors.length; |
| 6 | // N+K |
| 7 | for(int right=1;right < (n + k -1); right++){ // exp.. |
| 8 | // skip entire subarray |
| 9 | if(colors[right%n] == colors[(right-1)%n]){ |
| 10 | left = right; |
| 11 | } |
| 12 | if(right - left + 1 == k){ |
| 13 | res++; |
| 14 | left++; // move to next subarray or shrinking phase |
| 15 | } |
| 16 | } |
| 17 | return res; |
| 18 | } |
| 19 | } |
nothing calls this directly
no outgoing calls
no test coverage detected