diff --git a/Hashing/SubString.java b/Hashing/SubString.java index 3274264..b56ec4f 100644 --- a/Hashing/SubString.java +++ b/Hashing/SubString.java @@ -75,7 +75,7 @@ public static void main(String[] args){ } } /* - * public static ArrayList findSubstring(String a, final List b) { + * public ArrayList findSubstring(String a, final List b) { ArrayList result = new ArrayList(); if(b.size() == 0) return result; @@ -107,17 +107,29 @@ public static void main(String[] args){ } return result; } - public static boolean check(String s, int l, int n, HashMap map){ - String temp; - for(int i =0; i < n; i= i + l){ - temp = s.substring(i, i + l); - if(map.containsKey(temp)){ - if(map.get(temp) < 1) - return false; - else - map.put(temp, map.get(temp) - 1); - } + public boolean check(String s, int l, int n, HashMap map){ + String checkWord=s; + System.out.println(checkWord); + String temp; + for(int i =0; i < n; i= i + l){ + temp = s.substring(i, i + l); + if(map.containsKey(temp)){ + // if(map.get(temp) < 1) + // return false; + // else + map.put(temp, map.get(temp) - 1); + } + } + Iterator keyVals=map.values().iterator(); + boolean endResult=true; + while(keyVals.hasNext()){ + if(keyVals.next()==0){ + + }else{ + endResult=false; + return endResult; } - return true; } - */ \ No newline at end of file + return endResult; +} + */