Grid Challenge Discussions | | HackerRank

Grid Challenge

  • + 0 comments

    Python solution

    def gridChallenge(grid):
        sorted_grid = ["".join(sorted(row)) for row in grid]
        num_cols = len(sorted_grid[0])
        num_rows = len(sorted_grid)
        
        for col_idx in range(num_cols):
            columns = []
            for row_idx in range(num_rows):
                columns.append(sorted_grid[row_idx][col_idx])
           
            if columns != sorted(columns):
                return "NO"
        return "YES"