String window problem

I cant understand the approach for this problem from editorial.

@Arnabiswas hi,use this aaproach:
1)First check if length of string is less than the length of given pattern, if yes then "no such window can exist ".
Store the occurrence of characters of given pattern in a hashtable
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 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.

Why it is necessary to store occurance?

please tell me the logic of this :grinning:

@Arnabiswas hey ,basically hm ocuurance se ye check krrhr hai ki us particular window me woh element kitna bar arha hai ,agrr no of ocuurence in window of a character is same as bigger string than woh exist krrha hai us window me and hm use apne min ans me consider kr skte hai .Hope you get it.

@Arnabiswas Also you may refer this blog for easy understanding with figures:

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.