Simple dp solution
\njava []\nclass Solution {\n    Integer[][]dp=new Integer[101][1024];\n    int rr;\n    int cc;\n    public int maxScore(List<List<Integer>> grid) {\n       rr
\n```java []\nclass Solution {\n    Integer[][]dp=new Integer[101][1024];\n    int rr;\n    int cc;\n    public int maxScore(List<List<Integer>> grid) {\n       rr=grid.size();\n       cc=grid.get(0).size();\n       \n\n        return f(1,0,grid);\n    }\n    public int f(int val,int mask,List<List<Integer>> grid){\n        if((val>100))return 0;\n      if(dp[val][mask]!=null)return dp[val][mask];\n     int ans=-1;//dp[val][mask];\n     \n        ans=f(val+1,mask,grid);\n     for (int r = 0; r < rr; r ++) {\n            if ((mask & (1 << r))!=0) continue;\n            \n            for (int c = 0; c < cc; c ++) {\n                if (grid.get(r).get(c) != val) continue;\n                \n                ans = Math.max (ans, val + f(val+1,mask|(1<<r),grid));\n            }\n        }\n\n       // System.out.println(val+" "+mask+" "+ans);\n        return dp[val][mask]=ans;\n    }\n}\n```
['Java']