Find Special Substring of Length K - Practice Coding | SlaveCode
0
0123456789
0
0123456789
:
0
0123456789
0
0123456789
3456. Find Special Substring of Length K
Easy
10 Points
String
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:
Return true if such a substring exists. Otherwise, return false.
Examples
Example 1
Input: s = "aaabaaa", k = 3
Output: true
Explanation:
The substring s[4..6] == "aaa" satisfies the conditions.
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.
3456. Find Special Substring of Length K
Easy
10 Points
String
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:
Return true if such a substring exists. Otherwise, return false.
Examples
Example 1
Input: s = "aaabaaa", k = 3
Output: true
Explanation:
The substring s[4..6] == "aaa" satisfies the conditions.
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.