Smallest Substring of All Characters Instructions:

  • Create a map to store the unique chars array value, set key as 0.
  • start to loop through string chars
  • if key don’t exist then CONTINUE (back to step 2)
  • if loop index == 0 : uniqueCount += 1
  • increase countMap value by 1
  • What do you mean by shortest here, the sub string will be equal to length of arr?
  • Sliding window
  • The hints and answer seem incorrect on pramp, they have tried to rephrase problem from here but failed in some conditions, https://www.geeksforgeeks.org/smallest-window-contains-characters-string/
arr = ['a', 'b', 'c']
sample_str = 'andacb' # output acb
char_map = {}
unique_chars_len = 0
smallest_substr_len = 0 
for c in arr:
	char_map[c] = 0
	unique_chars_len += 1
 
for c in sample_str:
	if c not in char_map:
		continue
 
	
	
 

My question