String window problem

It is not passing 3 test cases out of 10, please tell the error.

What have you done? So many while looop!!
Try to follow this :
1.First check if length of string is less than the length of given pattern, if yes then "no such window can exist ".
2.Store the occurrence of characters of given pattern in a hash_pat[].
3.Start matching the characters of pattern with the characters of string i.e. increment count if a character matches
4.Check if (count == length of pattern ) this means a window is found
5.If such window found, try to minimize it by removing extra characters from beginning of current window.
6.Update min_length
7.Print the minimum length window.

1 Like

please have a look at this implementation, its very simple

1 Like