Given a string `s` and an integer `k`, return _the number of substrings in_ `s` _of length_ `k` _with no repeated characters_.

**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.

**Constraints:**

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


def num_k_len_substr_no_repeats(s: str, k: int) -> int:
    n = len(s)
    if k > n:
        return 0

    result = 0
    window = set()

    i = 0
    for j in range(n):
        while s[j] in window:
            window.remove(s[i])
            i += 1
        window.add(s[j])
        if j - i + 1 == k:
            result += 1
            window.remove(s[i])
            i += 1

    return result
