CoolFace
Datasetpublic

TheRealSamuel/LeetCodeProblem

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes572downloads
1{2    "id": 3709,3    "name": "find_special_substring_of_length_k",4    "difficulty": "Easy",5    "link": "https://leetcode.com/problems/find-special-substring-of-length-k/",6    "date": "2025-02-09 00:00:00",7    "task_description": "You are given a string `s` and an integer `k`. Determine if there exists a substring of length **exactly** `k` in `s` that satisfies the following conditions: The substring consists of **only one distinct character** (e.g., `\"aaa\"` or `\"bbb\"`). If there is a character **immediately before** the substring, it must be different from the character in the substring. If there is a character **immediately after** the substring, it must also be different from the character in the substring. Return `true` if such a substring exists. Otherwise, return `false`. **Example 1:** **Input:** s = \"aaabaaa\", k = 3 **Output:** true **Explanation:** The substring `s[4..6] == \"aaa\"` satisfies the conditions. It has a length of 3. All characters are the same. The character before `\"aaa\"` is `'b'`, which is different from `'a'`. There is no character after `\"aaa\"`. **Example 2:** **Input:** s = \"abc\", k = 2 **Output:** false **Explanation:** There is no substring of length 2 that consists of one distinct character and satisfies the conditions. **Constraints:** `1 <= k <= s.length <= 100` `s` consists of lowercase English letters only.",8    "public_test_cases": [9        {10            "label": "Example 1",11            "input": "s = \"aaabaaa\", k = 3",12            "output": "true "13        },14        {15            "label": "Example 2",16            "input": "s = \"abc\", k = 2",17            "output": "false "18        }19    ],20    "private_test_cases": [21        {22            "input": [23                "\"npiqeyedtwkxpacknwmuiqjwfcjoaspqjjrkedlpsecmlbdzjhmmadyuffboureyfg\"",24                825            ],26            "output": false27        },28        {29            "input": [30                "\"frfibfvbjbembzqmpygdsutmdnefweotbbutvihqaodnvkhlovtyhvgksijkrvqclikuzdgjee\"",31                5332            ],33            "output": false34        },35        {36            "input": [37                "\"ow\"",38                239            ],40            "output": false41        },42        {43            "input": [44                "\"kcbgeeldqbijcfbfwkxjtzrrgvcplhftpaz\"",45                1046            ],47            "output": false48        },49        {50            "input": [51                "\"puvexiblpdkdberrcjucrehjrzizyobtittk\"",52                1553            ],54            "output": false55        },56        {57            "input": [58                "\"nbmzvrvoljbqwtwmj\"",59                160            ],61            "output": true62        },63        {64            "input": [65                "\"laluchhncipksfyucufozhrkflsrbeqkrnrvyiaihwkptuiquycoxfpmelchzdciilupqsdaqkkyjnkzdyejhatdzjdcco\"",66                6167            ],68            "output": false69        },70        {71            "input": [72                "\"wohlljnaddwmpuwamgkiyfvtuzbpcjhlvohkrwnpaiolofylskymmeouuoztkpqbcxjuxqpkqhgjmuutdxdjmjdkwkamikp\"",73                3274            ],75            "output": false76        },77        {78            "input": [79                "vzlfovuxlagnyfozvkgmnjtvgvrpfrdxvljppyqmgaclfmeyezxuzlkplyodjppbszuffvacllvhrhtxajwokdyov",80                781            ],82            "output": false83        },84        {85            "input": [86                "dgjbknmicwjojjbtmhtbfqlkssfvcmxnxvqagiwbuhjkikhxkqevbegxzwanhzulrxvve",87                6488            ],89            "output": false90        }91    ],92    "haskell_template": "hasSpecialSubstring :: String -> Int -> Bool\nhasSpecialSubstring s k ",93    "ocaml_template": "let hasSpecialSubstring (s: string) (k: int) : bool =  ",94    "scala_template": "def hasSpecialSubstring(s: String,k: Int): Boolean = { \n    \n}",95    "java_template": "class Solution {\n    public boolean hasSpecialSubstring(String s, int k) {\n        \n    }\n}",96    "python_template": "class Solution(object):\n    def hasSpecialSubstring(self, s, k):\n        \"\"\"\n        :type s: str\n        :type k: int\n        :rtype: bool\n        \"\"\"\n        "97}