🔥 JAVA 2️⃣-pointer sliding window || Simple Explanation 👀😄
\uD83D\uDCCC 2 pointer Sliding window with 2 Hashmaps \uD83D\uDC49\uD83C\uDFFB \'Acquired\' and \'Required\' \n\n   ## \u2705 At any point of time we will find 
# \uD83D\uDCCC 2 pointer Sliding window with 2 Hashmaps \uD83D\uDC49\uD83C\uDFFB \'Acquired\' and \'Required\' \n\n   ## \u2705 At any point of time we will find : Minimum window substring starting from ith index (i.e. first pointer )\n   \n \u270D\uD83C\uDFFB **Notations** : \n1.   acquired -> Hashmap containing details of current window elements\n2.   required -> HashMap containing details of required no. of elements\n3.   i -> left / back   pointer\n4.   j -> right / front  pointer\n   \n   \uD83C\uDFAF **Logic** :\n   \n   step 1 :  Keep moving the front pointer (j) until your window do not contains all the required elements\n   step 2 : Note the current window size and update the ans ( if required )\n   step 3 : Once your window contain all the required elements, keep moving the back pointer (i) till your window contains all the                       req. elements and keep on updating the ans and \'acquired\' hashmap accordingly.\n   step 4 : repeat step 1\n \n   \n   \n   \n```\nclass Solution {\n    public String minWindow(String s, String t) {\n        int l = s.length();\n        int m = t.length();\n        \n        HashMap<Character,Integer> required = new HashMap<>();\n        for(char c : t.toCharArray())\n        {\n            int ov = required.getOrDefault(c, 0);\n            required.put(c, ov+1);\n        }\n        \n        HashMap<Character,Integer> acquired = new HashMap<>();\n        int min = Integer.MAX_VALUE;\n        String ans="";\n        int i = 0;\n        int j=0;\n        int found = 0;\n        while(i<l)\n        {\n            while(j<l && found!=m)\n            {\n                char cc = s.charAt(j);\n                if(required.containsKey(cc))  // one useful character we have found\n                {\n                    int ov = acquired.getOrDefault(cc, 0);\n                    acquired.put(cc, ov+1);\n                    if(acquired.get(cc) > required.get(cc)){}  // character was found more than its requirement\n                    else found += 1;\n                } \n                j++;\n            }\n            \n            int window_size = j-i;\n            if(found==m && window_size<min)\n            {\n                min = window_size;\n                ans = s.substring(i,j);\n            }\n            \n            if(required.containsKey(s.charAt(i))) // useful character we might loose\n            {\n                int ov = acquired.get(s.charAt(i));\n                acquired.put(s.charAt(i), ov-1);\n                if(acquired.get(s.charAt(i)) < required.get(s.charAt(i))) found -= 1;  // we lost one useful character\n            }\n            \n            i++;\n            \n        }\n        \n      return ans;\n    }\n}\n```\n\n\uD83D\uDCCC Please upvote if you lked the approach \uD83D\uDE0A\uD83D\uDE42
['Two Pointers', 'Sliding Window', 'Java']