brute force dp on doubly sorted grid
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n    def maxScore(self, grid: List[List[int]]) -> int:\n        # dp on double sorted grid\n        def gmax(grid):\n            # keep grid sorted\n            grid = sorted([sorted(row, reverse=True) for row in grid], reverse=True)\n            nrow = len(grid)\n            # switch cases, \n            # 0 rows\n            if nrow==0:\n                return 0\n            # 1 row\n            if nrow==1:\n                return grid[0][0]\n            # >= 2 rows, unique max\n            if grid[0][0] > grid[1][0]:\n                return grid[0][0] + gmax(new_grid(grid, 0))\n            # >= 2 rows, multiple max\n            return max(grid[0][0] + gmax(new_grid(grid, i)) \n                       for i in range(nrow) if grid[0][0] == grid[i][0])\n        \n        # build new grid by choosing the first element of row i\n        def new_grid(grid, i):\n            ngrid = []\n            for j, row in enumerate(grid):\n                if j != i:\n                    rowtemp = [r for r in row if r!=grid[0][0]]\n                    # only append non-null rows\n                    if rowtemp:\n                        ngrid.append(rowtemp)\n            return ngrid\n\n        return gmax(grid)\n```
['Dynamic Programming', 'Sorting', 'Python3']