Tap here to switch tabs
Problem
Submissions

Problem: Find Special Substring of Length K

med
30 min
Try to solve the Find Special Substring of Length K problem.

Statement

You are given a string s and an integer k.

Determine if there exists a substring of s of length kk that satisfies all of the following conditions:

  • The substring consists of exactly 11 distinct character.

  • If a character immediately precedes the substring, it must be different from the character inside the substring.

  • If a character immediately succeeds the substring, it must be different from the character inside the substring.

Return true if such a substring exists, or false otherwise.

Constraints:

  • 1≤k≤1 \leq k \leq s.length ≤100\leq 100

  • s consists of lowercase English letters only.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Special Substring of Length K

med
30 min
Try to solve the Find Special Substring of Length K problem.

Statement

You are given a string s and an integer k.

Determine if there exists a substring of s of length kk that satisfies all of the following conditions:

  • The substring consists of exactly 11 distinct character.

  • If a character immediately precedes the substring, it must be different from the character inside the substring.

  • If a character immediately succeeds the substring, it must be different from the character inside the substring.

Return true if such a substring exists, or false otherwise.

Constraints:

  • 1≤k≤1 \leq k \leq s.length ≤100\leq 100

  • s consists of lowercase English letters only.