C++ || Sliding Window || Map || String || Easy Explanation || Simple
Approach \n- Sliding Window Technique!!\n- Map for storing Frequency\n\n# Complexity\n- Time complexity: O(m+n)\n Add your time complexity here, e.g. O(n) \n\n-
# Approach \n- Sliding Window Technique!!\n- Map for storing Frequency\n\n# Complexity\n- Time complexity: O(m+n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n\n    // Sliding Window Approach\n    // Time Complexity:- O(m+n)\n    // Space Complexity:- O(n)\n    \n    string minWindow(string s, string t) {\n        vector<string> ans;\n        map<char,int> mp;\n\n        // Storing frequency of each character resent in t string\n        for(auto i: t){\n            mp[i]++;\n        }\n\n        // Starting Point of window\n        int i=0;\n        // Ending Point of window\n        int j=0;\n        int count=mp.size();\n        // st and mini for storing starting and ending point of our resultant substring\n        int st=0;\n        int mini=INT_MAX;\n\n        // Actual Approach\n        while(j<s.size()){\n            mp[s[j]]--;\n\n            if(mp[s[j]]==0){\n                count--;\n            }\n\n            if(count==0){\n                while(count==0){\n                   if((j-i+1)<mini){\n                       mini=j-i+1;\n                       st=i;\n                   }\n\n                   mp[s[i]]++;\n\n                   if(mp[s[i]]>0){\n                       count++;\n                   }\n\n                   i++;\n                }\n            }\n            \n            j++;\n        }\n      \n        // If No valid ans possible return empty string else return the final substring \n        if(mini==INT_MAX){\n            return "";\n        }\n        else{\n            return s.substr(st,mini);\n        }\n\n    }\n};\n```
['String', 'Ordered Map', 'Sliding Window', 'C++']