Solution using constraints | O(100*2^10) | Recursion(Backtracking) | C++
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:\nO( 100* 2^10 )\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic: \n    int solve(int val,vector<vector<int>>&values,unordered_set<int>st) {\n            if(val==0)\n                return 0;    \n    \n            int score=0,empty=1;\n            for(int j=0;j<10;j++) {\n                if(values[val][j]==1 && st.find(j)==st.end()) {\n                    empty=0;\n                    st.insert(j);\n                    score=max(score,val+solve(val-1,values,st));\n                    st.erase(j);\n                }                \n            } \n            if(empty)\n                score=max(score,solve(val-1,values,st));  \n\n            return score;\n    }\n    int maxScore(vector<vector<int>>& grid) {\n        int m=grid.size(),n=grid[0].size();\n        vector<vector<int>>values(101,vector<int>(10));\n        unordered_set<int>st;\n\n        for(int i=0;i<m;i++)\n            for(int j=0;j<n;j++)\n                values[grid[i][j]][i]=1;\n\n        return solve(100,values,st);\n    }\n};\n```
['Backtracking', 'Depth-First Search', 'Recursion', 'C++']