Grid Challenge Discussions | | HackerRank

Grid Challenge

  • + 0 comments

    Python 3 solution:

    from typing import Literal
    
    
    def gridChallenge(grid: list[str]) -> Literal["NO", "YES"]:
        _grid = iter(grid)
        last_row = sorted(next(_grid))
        for row in _grid:
            row = sorted(row)
            if any(i < j for i, j in zip(row, last_row)):
                return "NO"
            last_row = row
        return "YES"