c++ || Advance || Sliding window || Fast
Please upvote, your one upvote makes me happy\n\n^____^\n\nHere is the code\n\n\nclass Solution {\npublic:\n\n    string minWindow(string str, string pat) {\n  
**Please upvote, your one upvote makes me happy**\n\n^____^\n\n**Here is the code**\n\n```\nclass Solution {\npublic:\n\n    string minWindow(string str, string pat) {\n           \n    int len1 = str.length();\n    int len2 = pat.length();\n        \n    const int no_of_chars = 256;\n\n    if (len1 < len2) {\n        return "";\n    }\n\n    int hash_pat[no_of_chars] = { 0 };\n    int hash_str[no_of_chars] = { 0 };\n\n    \n    for (int i = 0; i < len2; i++)\n        hash_pat[pat[i]]++;\n\n    int start = 0, start_index = -1, min_len = INT_MAX;\n\n    int count = 0; \n    for (int j = 0; j < len1; j++) {\n        hash_str[str[j]]++;\n\n        if (hash_str[str[j]] <= hash_pat[str[j]])\n            count++;\n\n        if (count == len2) {\n          \n            while (hash_str[str[start]]\n                       > hash_pat[str[start]]\n                   || hash_pat[str[start]] == 0) {\n\n                if (hash_str[str[start]]\n                    > hash_pat[str[start]])\n                    hash_str[str[start]]--;\n                start++;\n            }\n\n            int len_window = j - start + 1;\n            if (min_len > len_window) {\n                min_len = len_window;\n                start_index = start;\n            }\n        }\n    }\n\n    if (start_index == -1) {\n     \n        return "";\n    }\n\n    return str.substr(start_index, min_len);\n\n    }\n};\n```\n\n**Keep coding Keep upvoting**
['C', 'Sliding Window']