FPEvalRepoPublic/LeetCodeMetaData
0399
1{2 "id": 3223,3 "name": "count-complete-substrings",4 "difficulty": "Hard",5 "link": "https://leetcode.com/problems/count-complete-substrings/",6 "date": "2023-11-26",7 "task_description": "You are given a string `word` and an integer `k`. A substring `s` of `word` is **complete** if: Each character in `s` occurs **exactly** `k` times. 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`. Return _the number of **complete **substrings of_ `word`. A **substring** is a **non-empty** contiguous sequence of characters in a string. **Example 1:** ``` **Input:** word = \"igigee\", k = 2 **Output:** 3 **Explanation:** The complete substrings where each character appears exactly twice and the difference between adjacent characters is at most 2 are: **igig**ee, igig**ee**, **igigee**. ``` **Example 2:** ``` **Input:** word = \"aaabbbccc\", k = 3 **Output:** 6 **Explanation:** The complete substrings where each character appears exactly three times and the difference between adjacent characters is at most 2 are: **aaa**bbbccc, aaa**bbb**ccc, aaabbb**ccc**, **aaabbb**ccc, aaa**bbbccc**, **aaabbbccc**. ``` **Constraints:** `1 <= word.length <= 105` `word` consists only of lowercase English letters. `1 <= k <= word.length`",8 "test_case": [9 {10 "label": "Example 1",11 "input": "word = \"igigee\", k = 2",12 "output": "3 "13 },14 {15 "label": "Example 2",16 "input": "word = \"aaabbbccc\", k = 3",17 "output": "6 "18 }19 ],20 "constraints": [21 "Each character in s occurs exactly k times.",22 "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.",23 "1 <= word.length <= 105",24 "word consists only of lowercase English letters.",25 "1 <= k <= word.length"26 ],27 "python_template": "class Solution(object):\n def countCompleteSubstrings(self, word, k):\n \"\"\"\n :type word: str\n :type k: int\n :rtype: int\n \"\"\"\n ",28 "java_template": "class Solution {\n public int countCompleteSubstrings(String word, int k) {\n \n }\n}",29 "metadata": {30 "func_name": "countCompleteSubstrings"31 }32}