Grid Challenge Discussions | | HackerRank

Grid Challenge

  • + 0 comments

    My Python solution given the fact that some test cases come with non-square grids

    def gridChallenge(grid):
        # Write your code here
        n = len(grid)
        sortedRows = [sorted(row) for row in grid]
        if len(sortedRows[0]) != n:
            m = len(sortedRows[0])
        else:
            m = n
        for i in range(m):
            for j in range(1, n):
                if sortedRows[j][i] < sortedRows[j-1][i]:
                    return 'NO'
        return 'YES'