Here working perfectly,but showing tle on leetcode ,so another way of doing this?

Hey @Muskan-Gupta-598128740703036
Your code is perfect. Leetcode test case might be unnecessarily time strict. Sometimes their checkers are even faulty. So don’t worry about that.
One place you can improve your code is using frequency array instead of hashmap. Although hashmap theoretically works in 0(1) it is more time consuming than an array.
Check this too once https://www.geeksforgeeks.org/find-the-smallest-window-in-a-string-containing-all-characters-of-another-string/

If your doubt is resolved please mark it as closed.

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.