sir , i tried the code but not getting how to get shortest substring of s1 that contains all the characters of s2 . Could you please provide me the solution so i can dry run it
Need help in this particular question
hello @siddhant_samal
logic->
- First check if the length of the string is less than the length of the given pattern, if yes then “ no such window can exist “.
- Store the occurrence of characters of the given pattern in a hash_pat[].
- Start matching the characters of pattern with the characters of string i.e. increment count if a character matches.
- Check if (count == length of pattern ) this means a window is found.
- If such a window found, try to minimize it by removing extra characters from the beginning of the current window.
- Update min_length.
- Print the minimum length window.
refer this ->
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.