Simple bitmask solution in Python
Approach\nSimple bitmask solution\n\n# Code\npython3 []\nclass Solution:\n    def maxScore(self, grid: List[List[int]]) -> int:\n        lr = len(grid)\n       
# Approach\nSimple bitmask solution\n\n# Code\n```python3 []\nclass Solution:\n    def maxScore(self, grid: List[List[int]]) -> int:\n        lr = len(grid)\n        lc = len(grid[0])\n        values = dict()\n        for r in range(lr):\n            for c in range(lc):\n                x = grid[r][c]\n                if x not in values:\n                    values[x] = []\n                values[x].append(r)\n        xs = sorted(values.keys(), key=lambda x: -x)\n        # print(xs)\n        dp = [0 for j in range(2**lr)]\n        for x in xs:\n            for j in range(2**lr-1, -1, -1):\n                for r in values[x]:\n                    if j>>r & 1:\n                        dp[j] = max(dp[j], dp[j^1<<r] + x)\n        return dp[2**lr-1]\n```
['Python3']