BlackFridaySale

Join the waitlist for an extra exclusive deal

Extra savings end in
01Days
04Hrs
04Mins
29Secs
Limited spots only

579. Find K-Length Substrings With No Repeated Characters

You are given a string s and an integer k. You need to find all the substrings of length k that do not contain any repeated characters. Return the count of all such substrings.

Example 1:

Input: s = "havefunonleetcode", k = 5

Output: 6

Explanation: There are 6 substrings they are: 'havef','avefu','vefun','efuno','etcod','tcode'.

Example 2:

Input: s = "home", k = 5

Output: 0

Explanation: Notice k can be larger than the length of s. In this case, it is not possible to find any substring.

Now Your Turn!

Pick the correct output for the given input

Input: s="takeuforward", k=3

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1 <= s.length <= 104
  • s consists of lowercase English letters.
  • 1 <= k <= 104

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

0
class Solution {
public:
int numKLenSubstrNoRepeats(string s, int k) {
//Your Code Goes Here
}
};
Test Case

Input:

K
S