Simple recursive solution with Memoization
Intuition\nRecursively go in the bottom and right direction making a note of max. Use memoization to optimize.\n\n# Approach\n- Start from top left (0, 0)\n- Fi
# Intuition\nRecursively go in the bottom and right direction making a note of max. Use memoization to optimize.\n\n# Approach\n- Start from top left (0, 0)\n- Find the max of bottomMax and rightMax\n- Update if max at the current cell is greater\n- Update the memoized cell and return\n\n# Complexity\n- Time complexity:\nO(m * n)\n\n- Space complexity:\nO(m * n)\n\n# Code\n```\n/**\n * @param {number[][]} grid\n * @return {number}\n */\nvar maxScore = function (grid) {\n    const m = grid.length, n = grid[0].length;\n    const dp = Array.from({ length: m }, () => []);\n    let max = -Infinity;\n    getMaxScore(0, 0);\n    return max;\n\n    function getMaxScore(row, col) {\n        if (row >= m || col >= n) {\n            return -Infinity;\n        }\n\n        if (dp[row][col] !== undefined) {\n            return dp[row][col];\n        }\n\n        const bottom = getMaxScore(row + 1, col);\n        const right = getMaxScore(row, col + 1);\n        const currentMax = Math.max(bottom, right);\n        max = Math.max(max, currentMax - grid[row][col]); // update max\n        return dp[row][col] = Math.max(grid[row][col], currentMax);\n    }\n};\n```
['Dynamic Programming', 'Recursion', 'Memoization', 'JavaScript']