Substrings of size K with K distinct chars

Given a string s and an int k, return all unique substrings of s of size k with k distinct characters.

Examples

Example 1:

Input: awaglknagawunagwkwagl = abcabc,k = 4
Output: ["wagl", "aglk", "glkn", "lkna", "knag", "gawu", "awun", "wuna", "unag", "nagw", "agwk", "kwag"]
Explanation:

Substrings in order are: wagl, aglk, glkn, lkna, kna", gawu, awun, wuna, unag, nagw, agwk, kwag, wagl wagl is repeated twice, but is included in the output once.

Example 2:

Input: s = abcabc,k = 3
Output: ["abc", "bca", "cab"]

Example 3:

Input: abacab = abcabc,k = 3
Output: ["bac", "cab"]

Constraints:

The input string consists of only lowercase English letters [a-z] 0 ≤ k ≤ 26

Try it yourself