[C++] [Sliding Window] - Simple and easy to understand with explanation | O(n) time complexity
Make two frequency count array and store the frequency of t initially\n2. If character match with the characters of t, increment the count variable\n3. if count
1. Make two frequency count array and store the frequency of t initially\n2. If character match with the characters of t, increment the count variable\n3. if count==length of t (t_len) => we found a window with all characters of t\n4. Minimize the window size by removing extra characters from the start of window (using win_left for this).\n5. Keep updating window of smaller length \n6. Print substring of the smallest window found.\n\n```\nclass Solution {\npublic:\n    string minWindow(string s, string t) {\n        int s_len=s.length();\n        int t_len=t.length();\n        \n        vector<int> freq_t(256,0);\n        vector<int> freq_s(256,0);\n        for(int i=0;i<t_len;i++)\n            freq_t[t[i]]++;\n        \n        int win_left=0;               //Current window will always be [win_left,i]\n        int ans=INT_MAX,ans_left;     //Track smallest window\n        int count=0;                  //For tracking number of characters encountered of string t in string s\n\t\t\n\t\t\n        for(int i=0;i<s_len;i++){\n            if(freq_t[s[i]]>0 && freq_t[s[i]]>freq_s[s[i]])\n                count++;\n            freq_s[s[i]]++;\n            if(count==t_len){ \n                /*\n\t\t\t\tAll characters required are in current window\n                Now , try to minimize window by removing extra character at the start of window\n                */\n\t\t\t\t\n                while(win_left<i &&         //Extra frequency or zero frequency characters\n                      (freq_t[s[win_left]]<freq_s[s[win_left]] || freq_t[s[win_left]]==0)){\n                    \n                    if(freq_t[s[win_left]]<freq_s[s[win_left]])\n                        freq_s[s[win_left]]--;\n                    win_left++;\n                }\n                if(ans>(i-win_left+1)){\n                    ans=(i-win_left+1);\n                    ans_left=win_left;    \n                }\n            }\n        }\n        if(ans==INT_MAX)\n            return "";\n        return s.substr(ans_left,ans);\n    }\n};\n```
['C', 'Sliding Window', 'C++']