java counting sliding window
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public  int countCompleteSubstrings(String word, int k) {\n\n        // 1. word\uB97C 0~n-1\uAE4C\uC9C0 \uC21C\uD68C\uD558\uBA74\uC11C \n        //   1) 1]   idx = (int)(word.charAt(i)-\'a\')   (condition 2\uC5D0 \uC758\uD574 \uAC04\uACA9\uC774 2\uC774\uD558\uC77C \uB54C\uB9CC \uC774\uC5B4\uC9C4\uB2E4.)\n        //         i\uC758 char\uAC12\uACFC i-1\uC758 char\uAC12\uC758 \uCC28\uC774\uAC00 2\uBCF4\uB2E4 \uD06C\uBA74 \n        //         start\uB97C i\uB85C \uBC14\uAFB8\uACE0 count\uB97C 0\uC73C\uB85C \uCD08\uAE30\uD654 \uD55C\uB4A4\uC5D0 \n        //         count[idx] \uB97C \uD558\uB098 \uC99D\uAC00\uC2DC\uCF1C\uC900\uB2E4. \n        //      2] 2\uBCF4\uB2E4 \uC791\uAC70\uB098 \uAC19\uC73C\uBA74  count[idx] \uB97C \uD558\uB098 \uC99D\uAC00\uC2DC\uCF1C\uC900\uB2E4. \n        \n        //   2) count[idx] \uAC12\uC774 k \uBCF4\uB2E4 \uD06C\uBA74 k\uAC00 \uB420 \uB54C\uAE4C\uC9C0 \n        //      start\uB97C \uC99D\uAC00\uC2DC\uD0A4\uBA74\uC11C \uD574\uB2F9 \uC790\uB9AC\uC758 \uAC12\uC744 count[] \uBC30\uC5F4\uC5D0\uC11C \uAC10\uC18C\uC2DC\uCF1C\uC900\uB2E4. \n\n        //   3) count[idx] \uB9C8\uC9C0\uB9C9\uC5D0 \uD3EC\uD568\uB41C index i\uC758 char\uC758 \uAC1C\uC218\uAC00 k\uAC00 \uB418\uC9C0 \uC54A\uC73C\uBA74 \n        //      start~i \uAE4C\uC9C0\uC758 \uD574\uB2F9 subString\uC740 \uD655\uC778\uD574\uBD10\uC57C \uC870\uAC74\uC744 \uB9CC\uC871\uC2DC\uD0AC \uC218 \uC5C6\uC73C\uBBC0\uB85C continue;\n\n        //   4) count[] \uB97C copyCount[] \uC5D0 copy \uD55C\uB2E4\uC74C\n        //      index start\uBD80\uD130 \uB300\uC751 \uB418\uB294 char\uB97C copyCount\uC5D0\uC11C \uD558\uB098\uC529 \uC81C\uAC70\uC2DC\uCF1C\uC8FC\uBA74\uC11C \n        //      \uC870\uAC74\uC5D0 \uB9CC\uC871\uC2DC\uD0A4\uB294 \uC9C0 \uD655\uC778\uD55C\uB2E4. \uB9CC\uC871\uD558\uBA74 result\uB97C \uD558\uB098 \uC99D\uC0AC\uD0A4\uC154\uC900\uB2E4. \n        //      \uB9CC\uC57D, copyCount[startIdx] \uC758 \uAC12\uC744 \uC904\uC600\uB294\uB370 index i\uC758 \uAC12\uC774 \uC904\uC5B4\uB4E4\uC73C\uBA74 \n        //      \uADF8\uB54C\uBD80\uD130\uB294 \uC870\uAC74\uC744 \uB9CC\uC871\uC2DC\uD0AC \uC218 \uC5C6\uC73C\uBBC0\uB85C break;\n\n        //  \u203B \uCD5C\uC545\uC758 case\uB294 1,000,000 / 26 = 3846 \n        //     a 3846 \uAC1C b 3846 \uAC1C c 3846\uAC1C .... z 3846 \uAC1C\uC758 string \uC5D0 k \uB294 3846 \uAC00 \uB420 \uAC83\uC774\uACE0 \n        //     3846\uBC88\uC9F8 \uB9C8\uB2E4 \uB9C8\uC9C0\uB9C9 \uC54C\uD30C\uBCB3\uC774 \uCC44\uC6CC\uC838\uC11C \uAC80\uC0AC\uB97C \uC9C4\uD589\uD560 \uAC83\uC774\uACE0\n        //     \uC54C\uD30C\uBCB3\uC774 \uCD1D 26\uAE00\uC790\uB77C \uCD5C\uB300 26(\uC54C\uD30C\uBCB3) * (1,000,000 - 3846) * 26(count array) \n\n        // The difference between two adjacent characters is at most 2. That is, for any two adjacent characters c1 and c2 in s, the absolute difference in their positions in the alphabet is at most 2. \n        // \uC704 \uC870\uAC74 \uB54C\uBB38\uC5D0 \uB9C8\uC9C0\uB9C9 index\uC758 \uAC12\uC774 k\uAC1C\uB85C \uB9DE\uCDB0\uC9C8 \uB54C\uB9C8\uB2E4 start~i\uAE4C\uC9C0 \uAC80\uC0AC\uD574\uB3C4 timeout \uC774 \uBC1C\uC0DD\uD558\uC9C0 \uC54A\uAC8C\uB054 \uBB38\uC81C\uAC00 \uAD6C\uC131\uB418\uC788\uB294 \uB4EF \uC2F6\uB2E4.\n\n\n      int count[] = new int[26];\n        int copyCount[] = new int[26];\n        \n        int result = 0;\n        int start = 0;\n        for(int i = 0; i < word.length(); i++) {\n\n            if ( i > 0 && Math.abs((int)(word.charAt(i)-\'a\') - (int)(word.charAt(i-1)-\'a\')) > 2) {\n                start = i;\n                Arrays.fill(count, 0);\n            }\n\n            int idx = (int)(word.charAt(i)-\'a\');\n            count[idx]++;\n\n            while ( start <= i && count[idx] > k )  {\n                \n                int startIdx = (int)(word.charAt(start)-\'a\');\n                count[startIdx]--;\n                start++;\n            }\n\n            if ( count[idx] != k ) {\n                continue;\n            } \n            \n\n            for(int j = 0; j < count.length; j++) {\n                copyCount[j] = count[j];\n            }\n\n\n            if ( check(copyCount, k)) {\n                // System.out.println(start + " " + i);\n                result++;\n            }\n\n            for(int j = start; j <= i; j++) {\n                int startIdx = (int)(word.charAt(j)-\'a\');\n                copyCount[startIdx]--;\n                if ( copyCount[idx] < k ) break;\n\n                if ( check(copyCount, k) ) {\n                    result++;                    \n                }\n            }\n        }\n\n        return result;\n\n    }\n\n    private  boolean check(int count[], int k) {\n        \n        boolean findK = false;\n        for(int i = 0; i < count.length; i++) {\n            if (count[i] == 0 ) continue;\n            if ( count[i] == k ) findK = true;\n            if ( count[i] != k ) return false;\n        }\n\n        if ( !findK) return false;\n\n        return true;\n    }\n}\n```
['Sliding Window', 'Counting', 'Java']