c++ solution using memoization
\nclass Solution {\npublic:\n    vector<int>mat[101];\n    int dp[101][(1<<10)+1];\n    int find(int num,int mask){\n        if(num==0) return 0;\n        if(dp
```\nclass Solution {\npublic:\n    vector<int>mat[101];\n    int dp[101][(1<<10)+1];\n    int find(int num,int mask){\n        if(num==0) return 0;\n        if(dp[num][mask]!=-1) return dp[num][mask];\n        int ans=find(num-1,mask);\n        for(auto &it:mat[num]){\n            if((mask&(1<<it))) continue;\n            ans=max(ans,num+find(num-1,mask|(1<<it)));\n        }\n        return dp[num][mask]= ans;\n    }\n    int maxScore(vector<vector<int>>& grid) {\n        memset(dp,-1,sizeof(dp));\n        for(int i=0;i<grid.size();i++){\n            for(int j=0;j<grid[0].size();j++){\n                mat[grid[i][j]].push_back(i);\n            }\n        }\n        return find(100,0);\n    }\n};\n```
['Dynamic Programming', 'Memoization', 'C', 'C++']