First we fill our our map with elements of string P, and we update thier frequencies. Then we iterate thorugh our string S. We are looking for elements that are in our unordered map. When we find all our elements that we wanted to find we need to check if there is not a smaller answer. We do that again by some form of window sliding.
Time complexity : O(|S|)
First we fill our our map with elements of string P, and we update thier frequencies. Then we iterate thorugh our string S. We are looking for elements that are in our unordered map. When we find all our elements that we wanted to find we need to check if there is not a smaller answer. We do that again by some form of window sliding. Time complexity : O(|S|)