Whoever thought that I would see this day, that python wouldn't pass and java would make way.
\nclass Solution {\n    \n    static int solve(int i,int j , int score,int [] stones,int [][] dp){\n        if (i == stones.length || j < 0 ){\n            retu
```\nclass Solution {\n    \n    static int solve(int i,int j , int score,int [] stones,int [][] dp){\n        if (i == stones.length || j < 0 ){\n            return 0;\n        }\n        if (dp[i][j]!=-1){\n            return dp[i][j];\n        }\n        int best = 0;\n        int op1 = score - stones[i] - solve(i+1,j,score - stones[i],stones,dp);\n        int op2 =  score  - stones[j] - solve(i,j-1,score - stones[j],stones,dp);\n        int best1 = Math.max(op1,op2);\n        best = Math.max(best,best1);\n        dp[i][j] = best;\n        return dp[i][j];\n            \n    }\n    \n    public int stoneGameVII(int[] stones) {\n        \n        int N =  stones.length;\n        \n        int [][]  dp= new int [N][N];\n        for(int i = 0; i < N; i++){\n            for (int j = 0; j < N ;j++){\n                dp[i][j] = -1;\n            }\n        }\n        \n        int total = 0;\n        for (int i = 0 ; i < N ; i++){\n            total+=stones[i];\n        }\n        \n        return solve(0,N-1,total,stones,dp);\n        \n        \n    }\n}\n```
['Java']