[C++] Sliding Window || Easy To Understand
IDEA\nWe keep expanding the window by moving the right pointer. When the window has all the desired characters, we contract (if possible) and save the smallest 
**IDEA**\nWe keep expanding the window by moving the right pointer. When the window has all the desired characters, we contract (if possible) and save the smallest window till now.\n`The answer is the smallest desirable window.`\n\u200B\n**EXAMPLE**\nFor eg. `S = "ABAACBAB" T = "ABC"`. Then our answer window is `"ACB"` and shown below is one of the possible desirable windows.\n![image](https://assets.leetcode.com/users/images/aa5e8ecb-faa5-4542-ba85-4c3c0b986b8d_1629012971.6332936.png)\n\n\u200B**ALGORITHM**\n* We start with two pointers, `leftleft` and `rightright` initially pointing to the first element of the string S.\n* We use the `rightright pointer` to expand the window until we get a desirable window i.e. a window that contains all of the characters of T.\n* Once we have a window with all the characters, we can move the left pointer ahead one by one. \n\t* \tIf the window is still a desirable one we keep on updating the minimum window size.\n\t* \tIf the window is not desirable any more, we repeat step 2 onwards.\n\n**SOLUTION**\n`In C++`\n```\nclass Solution {\npublic:\n    string minWindow(string s, string t) {\n       unordered_map<char,int> mp;\n        for(auto ch:t)\n        {\n            mp[ch]++;\n        }\n        int dist=mp.size() ;\n        unordered_map<char,int> window;\n        int count = 0 , ll = 0 , rr = 0 ;\n        int l = 0 , r = 0 , ans = INT_MAX ;\n        while(r<s.length())\n        {\n            window[s[r]]++ ;\n            if(mp.count(s[r]) and mp[s[r]]==window[s[r]])\n            {\n                    count++;\n            }\n            r++;\n            while(count == dist and l < r)\n            {\n                if(ans > r-l)\n                {\n                    ans= r - l ;\n                    ll = l ;\n                    rr = r ;\n                }\n                window[s[l]]-- ;\n                if(mp.count(s[l]) and window[s[l]] < mp[s[l]])\n                {\n                        count--;\n                }\n                l++;\n            }\n        }\n        return s.substr(ll,rr-ll);\n    }\n};\n```\n
[]