You are viewing a single comment's thread. Return to all comments →
Java
public static List<String> cavityMap(List<String> grid) { List<String> cavity = new ArrayList<>(grid); for (int r = 1; r < grid.size() - 1; r++) { for (int c = 1; c < grid.size() - 1; c++) { // Comparing ASCII value if (cell > grid.get(r).charAt(c - 1) && cell > grid.get(r).charAt(c + 1) && cell > grid.get(r - 1).charAt(c) && cell > grid.get(r + 1).charAt(c)) { cavity.set(r, cavity.get(r).substring(0, c) + "X" + cavity.get(r).substring(c + 1)); } } } return cavity; }
Seems like cookies are disabled on this browser, please enable them to open this website
Cavity Map
You are viewing a single comment's thread. Return to all comments →
Java