Simple Java Solution | Sliding Window
Kindly upvote, if it helps you!\n```\n public String minWindow(String s, String t) {\n        String result = "";\n        if(s.length() < t.length())\n        
Kindly upvote, if it helps you!\n```\n public String minWindow(String s, String t) {\n        String result = "";\n        if(s.length() < t.length())\n            return result;\n        int minWindow = Integer.MAX_VALUE;\n\t\t//We will use two variables \'have\' & \'need\' to keep a track whether the characters \n\t\t//we need have been encountered.\n        int need = t.length();\n        int have = 0;\n\t\t//Two hashmaps are used to store the character count.\n        Map<Character, Integer> sMap = new HashMap();\n        Map<Character, Integer> tMap = new HashMap();\n        for(int i=0; i<t.length(); i++){\n            char ch = t.charAt(i);\n            tMap.put(ch, tMap.getOrDefault(ch,0)+1);\n        }\n        int windowStart = 0;\n        for(int windowEnd = 0; windowEnd<s.length(); windowEnd++){\n            char ch = s.charAt(windowEnd);\n            sMap.put(ch, sMap.getOrDefault(ch,0)+1);\n\t\t\t//if we have encountered a useful character, we will increment have variable.\n            if(tMap.containsKey(ch) && sMap.get(ch)<=(tMap.get(ch))){\n                have++;\n            }\n\t\t\t//if have is equals to the need, means we got a substring in s having all the character of t\n            while(have==need){\n\t\t\t\t//check if its the mimimum substring till now\n                if(minWindow > windowEnd-windowStart+1){\n                    minWindow = windowEnd-windowStart+1;\n                    result = s.substring(windowStart, windowEnd+1);\n                }\n\t\t\t\t//now we will check, can we do better\n\t\t\t\t//is there a shorter substring\n                char charToRemove = s.charAt(windowStart);\n                if(sMap.get(charToRemove) == 1){\n                    sMap.remove(charToRemove);\n                }else{\n                sMap.put(charToRemove, sMap.get(charToRemove)-1);\n                }\n                windowStart++;\n\t\t\t\t//if we remove a useful char, decrementing have varaible\n                if(tMap.containsKey(charToRemove) && sMap.getOrDefault(charToRemove,0)<(tMap.get(charToRemove))){\n                    have--;\n                }\n            }\n        }\n        return result;\n    }
['Sliding Window', 'Java']