Easy to Understand, C++ solution Sliding Window's Most Important Question
Intuition\nAs we see the problems of String and Array, in which we have to optimise the solution and we have to perform sequential operations on those problems.
# Intuition\nAs we see the problems of String and Array, in which we have to optimise the solution and we have to perform sequential operations on those problems. We need to think of **Sliding Window**\n\n# Approach\nStore the elements of string \'t\' in a map, and compare that with the elements of string \'s\', and if they matches, then decrease the string \'s\' from the starting to get the minimum string.\n\n# Complexity\n- Time complexity: $$O(n)$$ \n\n- Space complexity: $$O(n)$$\n\n# Code\n```\nclass Solution {\npublic:\n    string minWindow(string s, string t) {\n        int n = s.size();\n        int m = t.size();\n\n        // This is the common sliding window problem\n\n        unordered_map<char,int> mp2;            // Storing values of string \'t\'\n        string ans;\n        for(auto x:t)\n        {\n            mp2[x]++;\n        }\n\n        unordered_map<char,int> mp;\n        int mini = INT_MAX;\n\n        int i=0,j=0;\n        while(j<n)\n        {\n            mp[s[j]]++;\n            \n            int flag = 0;\n            for(auto x:mp2)             // Checking if all values of mp2 are in mp1.\n            {\n                if(mp2[x.first]>mp[x.first])\n                {\n                    flag = 1;\n                    break;\n                }\n            }\n\n            if(flag==0)                 // If matches, then find min by decreasing the string \'s\'\n            {\n                while(mp[s[i]]>mp2[s[i]])\n                {\n                    mp[s[i]]--;\n\n                    if(mp[s[i]]==0) mp.erase(s[i]);\n                    i++;\n                }\n                if(mini>j-i+1)\n                {\n                    mini = min(mini,j-i+1);\n                    ans = s.substr(i,j-i+1);\n                }\n            }\n\n            j++;\n        }\n        return ans;\n    }\n};\n```
['Ordered Map', 'Sliding Window', 'C++']