#3456
Find Special Substring of Length K
pupil · 510 · lc easy +27 · 35.1% accepted · 64 likes · top 13%
Description
Given string s and integer k, decide whether s contains a run of exactly k identical characters such that:
- The run is composed of a single repeated character.
- The character directly preceding the run (if it exists) differs from it.
- The character directly following the run (if it exists) also differs from it.
Return true if such a run exists, or false otherwise.
Code
1
2
3