if (arr == null) { arr = new String[len]; for (int i = 0; i < arr.length; i++) { String w = reversed[i]; arr[i] = w.substring(w.length() - l) + "#" + w; // System.out.println(arr[i]); } index.put(l, arr); }
for (int i = 0; i < arr.length; i++) { if (arr[i].startsWith(query)) { ans = len - 1 - i; memo.put(query, ans); return ans; } }
return -1; } }
/** * Your WordFilter object will be instantiated and called as such: * WordFilter obj = new WordFilter(words); * int param_1 = obj.f(prefix,suffix); */