Solved in c using dynamic programming, Bottom up approach
\n\n# Complexity\n- Time complexity:\n O(n^2)\n\n- Space complexity:\n O(n^2) \n\n# Code\n\nint max(int a,int b){\n    return a>b?a:b;\n}\n\nint maxScore(int** 
\n\n# Complexity\n- Time complexity:\n $$O(n^2)$$\n\n- Space complexity:\n $$O(n^2)$$ \n\n# Code\n```\nint max(int a,int b){\n    return a>b?a:b;\n}\n\nint maxScore(int** grid, int gridSize, int* gridColSize) {\n    int res=-1e9;\n    int col=*gridColSize;\n    int row=gridSize;\n    int** dp=malloc(sizeof(int*)*gridSize);\n    for(int i=0;i<gridSize;i++){\n        dp[i]=malloc(sizeof(int)*gridColSize[i]);\n    }\n    for(int i=0;i<col;i++){\n            dp[gridSize-1][i]=-1e9;\n        }\n  \ndp[row-1][col-1]=-1e9;\nfor(int i=col - 2 ; i>=0;i--){\n    dp[row-1][i]=max(dp[row-1][i+1]+grid[row-1][i+1]-grid[row-1][i],grid[row-1][i+1]-grid[row-1][i] );\n}\n\nfor(int i=row-2;i>=0;i--){\n    dp[i][col-1]=max(dp[i+1][col-1]+grid[i+1][col-1]-grid[i][col-1],grid[i+1][col-1]-grid[i][col-1]);\n}\n\nfor(int i=row-2;i>=0;i--){\n    for(int j=col-2;j>=0;j--){\n        int bottom=dp[i+1][j];\n        int right=dp[i][j+1];\n        int b=grid[i+1][j]-grid[i][j];\n        int d=grid[i][j+1]-grid[i][j];\n        int max1=max(bottom+b,b);\n        int max2=max(right+d,d);\n        dp[i][j]=max(max1,max2);                  \n    }\n}\nfor(int i=0;i<row;i++){\n    for(int j=0;j<col;j++){\n       res=max(res,dp[i][j]);\n    }\n    }\nreturn res;\n}\n```
['Dynamic Programming', 'Memoization', 'C']