DP APPROACH || 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:\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```cpp []\nclass Solution {\npublic:\n    int dp[105][1030];\n    int solve(int idx,int mask,map<int,vector<int> >&arr){\n        if(idx==0){\n            return 0;\n        }\n        \n        if(dp[idx][mask] != -1){\n            return dp[idx][mask];\n        }\n        \n        int res=solve(idx-1,mask,arr);\n        \n        for(auto i:arr[idx]){\n            if((mask & (1<<i))==0){\n                res=max(res,idx+solve(idx-1,mask|(1<<i),arr));\n            }\n        }\n        \n        return dp[idx][mask]=res;\n    }\n    int maxScore(vector<vector<int>>& grid) {\n        memset(dp,-1,sizeof(dp));\n        map<int,vector<int> > arr;\n        int n=grid.size(),m=grid[0].size();\n        for(int i=0;i<n;i++){\n            for(int j=0;j<m;j++){\n                arr[grid[i][j]].push_back(i);\n            }\n        }\n        \n        return solve(100,0,arr);\n    }\n};\n```
['Dynamic Programming', 'Memoization', 'C++']