EXPLAINED | Easy to understand code with comments | 3ms
\nclass Solution {\n    public String minWindow(String s, String t) {\n        int[] count = new int[128];\n\n        // Count the characters in t\n        for 
```\nclass Solution {\n    public String minWindow(String s, String t) {\n        int[] count = new int[128];\n\n        // Count the characters in t\n        for (char ch : t.toCharArray()) count[ch]++;\n\n        char[] sourceStr = s.toCharArray();\n        String windowString = "";\n        int windowLeft = 0, windowRight = 0, charsFoundInWindow = 0,\n                totalCharsToFind = t.length(), minWindowLen = Integer.MAX_VALUE;\n        while (windowRight < sourceStr.length) {\n            int currentChar = sourceStr[windowRight];\n            // Reduce the count of current character\n            count[currentChar]--;\n            // If current character\'s count is greater than or equal to 0 if it was also present in target string t\n            // and we can say that we have found that character in current window so we increment charsFoundInWindow\n            if (count[currentChar] >= 0) {\n                charsFoundInWindow++;\n            }\n\n            // If we found a window containing all characters of t, find if it\'s smaller than the smallest window\n            // If yes, store the window in windowString to return finally.\n            while (charsFoundInWindow == totalCharsToFind) {\n                int currentWindowLen = windowRight - windowLeft + 1;\n                if(minWindowLen > currentWindowLen) {\n                    minWindowLen = currentWindowLen;\n                    windowString = s.substring(windowLeft, windowRight + 1);\n                }\n                // Now we need to reduce the window size from left to further look for smaller windows.\n                // The current leftmost character was already visited by right pointer windowRight earlier\n                // and we had reduced its count in count[]. So now we increment it because\n                // we need the count of that character in the remaining window.\n                count[sourceStr[windowLeft]]++;\n                // Now if the last character is greater than 0, it means that character was present in t but\n                // is not present in current window so we have to decrement charsFoundInWindow\n                if (count[sourceStr[windowLeft]] > 0) {\n                    charsFoundInWindow--;\n                }\n                windowLeft++;\n            }\n            windowRight++;\n        }\n        return windowString;\n    }\n}\n```
['Sliding Window', 'Java']