import java.util.HashMap; public class Min_window_substring { public static void main(String[] args) { String s1 = "timetopractice"; String s2 = "toc"; String s = solutions(s1,s2); System.out.println(s); } static String solutions(String s1, String s2){ String ans = " " ; HashMap map2 = new HashMap<>(); for (int i = 0; i< s2.length(); i++) { char ch = s2.charAt(i); map2.put(ch, map2.getOrDefault(ch,0) + 1); } int mct = 0; int dmct = s2.length(); HashMap map1 = new HashMap<>(); int i =-1; int j=-1; while(true){ boolean f1 = false; boolean f2 = false; //acquire while (i < s1.length()-1 && mct