Very Easy Solution in Python with clear approach -> time o(n*n), space(o(1))
Intuition\n Describe your first thoughts on how to solve this problem. \nIf you observe, you will notice that the answer will be path independent.\nyou just nee
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIf you observe, you will notice that the answer will be path independent.\nyou just need to find that max difference of grid[i][j] with the smallest value till i,j \n\nin other word if suppose current point is 2,3 then you need the samallest value till 2,3 index and substract with grid[2][3]\n\nDo this for all elements of 2D array, return the max of it\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nIn grid itself i am storing minimum value till that point and compares with previous, then find maximum of all\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n(N*N) since going to all cell once\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nconstant or o(1)\n\n# Code\n```\nclass Solution:\n    def maxScore(self, grid: List[List[int]]) -> int:\n        row=len(grid)\n        col=len(grid[0])\n\n        ans=-float(\'inf\')\n\n        for i in range(row):\n            for j in range(col):\n                top= grid[i-1][j] if i>0 else float(\'inf\')\n                left= grid[i][j-1] if j>0 else float(\'inf\')\n                \n                ans=max(ans,grid[i][j]-top,grid[i][j]-left)\n                grid[i][j]=min(grid[i][j],top,left)\n        return ans\n        \n\n        \n```
['Array', 'Dynamic Programming', 'Python3']