You are viewing a single comment's thread. Return to all comments →
static String gridSearch(String[] G, String[] P) { int n = G[0].length() - P[0].length() + 1; String delimiter = " "; String pad = String.format(".{%s}", n); String grid = String.format("%s%s", String.join(delimiter, G), String.join("", Collections.nCopies(n, delimiter))); String regex = String.format(".*%s%s.*", String.join(pad, P), pad); return grid.matches(regex)? "YES" : "NO"; }
The Grid Search
You are viewing a single comment's thread. Return to all comments →
Java 8 Solution (with Regex)