Skip to content

Practice Find Special Substring of Length K

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#3456
LeetCode Problem

Find Special Substring of Length K

Problem Statement

Given s and k, determine whether it contains a substring of length exactly k made of one repeated character, with any immediately preceding or following character different from that repeated character. Return true if such a substring exists, otherwise false.

Source: Find Special Substring of Length K on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "aaabaaa", k = 3
Output
true

# Example 2

Input
s = "abc", k = 2
Output
false

Constraints

1 <= k <= s.length <= 100
s consists of lowercase English letters only.

Related LeetCode Problems

Practice more problems similar to Find Special Substring of Length K.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.