You are viewing a single comment's thread. Return to all comments →
Java //O(n*n)
public static String gridChallenge(List<String> grid) { int n = grid.size(); int m = grid.get(0).length(); char[][] matrix= new char[n][m]; for(int i=0; i < n; ++i) { matrix[i] = grid.get(i).toCharArray(); Arrays.sort(matrix[i]); } for(int j=0; j < m; ++j) { for(int i=1; i < n; ++i) { if (matrix[i][j] < matrix[i-1][j]) { return "NO"; } } } return "YES"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Grid Challenge
You are viewing a single comment's thread. Return to all comments →
Java //O(n*n)