You are viewing a single comment's thread. Return to all comments →
C# Solution
public static List<string> cavityMap(List<string> grid) { for(int i = 1; i < grid.Count - 1; i++) for(int j = 1; j < grid[i].Length - 1; j++) if ( grid[i][j] > grid[i][j - 1] && // left grid[i][j] > grid[i][j + 1] && // right grid[i][j] > grid[i - 1][j] && // up grid[i][j] > grid[i + 1][j] // down ) grid[i] = updateString(j, grid[i]); return grid; } public static string updateString(int j, string previousString) { StringBuilder updatedString = new StringBuilder(previousString); updatedString[j] = 'X'; return updatedString.ToString(); }
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 →
C# Solution