FazeelUsmani / Amazon-SDE-Preparation

This repository includes all the interview preparation questions for Amazon SDE role
https://practice.geeksforgeeks.org/batch/Amazon-Test-Series
1.12k stars 291 forks source link

Create 06 smallestWindow.cpp #76

Closed Juro221 closed 3 years ago

Juro221 commented 3 years ago

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|)