In the Find K-Length Substrings With No Repeated Characters coding problem, you are given a string and an integer . You need to count how many substrings of length consist of entirely unique characters. If is larger than the length of the string or the alphabet size (26), the answer is zero.
Amazon frequently uses this to test a candidate's proficiency with the Sliding Window interview pattern. It evaluations whether you can efficiently maintain a character frequency state as you slide through a string. It’s a "clean" problem that checks if you can avoid brute force by using a Hash Table or a frequency array to perform updates in per character.
This problem uses a Fixed-size Sliding Window with a Hash Table (or frequency array).
uniqueCount variable.uniqueCount == k, the window is valid.uniqueCount.uniqueCount.s = "havefunonleetcode", k = 5
Set to check every substring from scratch ().Map object when a simple int[26] array would be much more performant.Always look for the "fixed-size" hint in sliding window problems. If the window size is constant, the logic is simpler than dynamic windows, but you must be precise with adding/removing elements simultaneously.