Beats 100%  || Hungarian matching
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 []\nfrom typing import List\nfrom collections import defaultdict\n\nclass Solution:\n    def maxScore(self, grid: List[List[int]]) -> int:\n        m, n = len(grid), len(grid[0])\n        \n   \n        graph = defaultdict(list)\n        for i, row in enumerate(grid):\n            for value in set(row):  \n                graph[value].append(i)\n        \n\n        def hungarian(graph):\n            match = {}\n            seen = set()\n            \n            def dfs(value):\n                for row in graph[value]:\n                    if row not in seen:\n                        seen.add(row)\n                        if row not in match or dfs(match[row]):\n                            match[row] = value\n                            return True\n                return False\n            \n            for value in sorted(graph.keys(), reverse=True):\n                seen.clear()\n                dfs(value)\n            \n            return match\n        \n    \n        matching = hungarian(graph)\n        \n   \n        return sum(matching.values())\n\n```
['Python3']