You are viewing a single comment's thread. Return to all comments →
#!/bin/python import sys def gridChallenge(grid): for i in range(n): grid[i] = sorted(grid[i]) for i in range(n-1): for j in range(n): if grid[i][j]>grid[i+1][j]: return "NO" return "YES" if __name__ == "__main__": t = int(raw_input().strip()) for _ in range(t): n = int(raw_input().strip()) grid = [] grid_i = 0 for grid_i in xrange(n): grid_t = str(raw_input().strip()) grid.append(grid_t) print gridChallenge(grid)
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 →
python solution
the thing that outrages me is the initial code is not correct.
you need to add a for loop for t instead of just read it as the code initiated.