3456. Find Special Substring of Length K
You are given a string
sand an integerk.Determine if there exists a substring of length exactly
kinsthat 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
trueif such a substring exists. Otherwise, returnfalse.
1 | class Solution { |