Solution
Intuition\nYou are given a 0-indexed m x n matrix grid consisting of positive integers.\n\nYou can start at any cell in the first column of the matrix, and trav
# Intuition\nYou are given a 0-indexed m x n matrix grid consisting of positive integers.\n\nYou can start at any cell in the first column of the matrix, and traverse the grid in the following way:\n\nFrom a cell (row, col), you can move to any of the cells: (row - 1, col + 1), (row, col + 1) and (row + 1, col + 1) such that the value of the cell you move to, should be strictly bigger than the value of the current cell.\nReturn the maximum number of moves that you can perform.\n# Approach\n1. Using DFS Method to backtrack , check for the higher value in the condition, given in the question.\n\n# Complexity\n- Time complexity:\nO(m.n)\n\n- Space complexity:\nO(m.n)\n\n# Code\n```python []\nclass Solution(object):\n    def maxMoves(self, grid):\n        def dfs(matrix, i, j, current_value):\n            # Check boundaries\n            if i < 0 or i >= len(matrix) or j < 0 or j >= len(matrix[0]):\n                return 0\n            if matrix[i][j] <= current_value:\n                return 0\n            if (i, j) in memo:\n                return memo[(i, j)]\n            temp = matrix[i][j]\n            max_move = 1 + max(\n                dfs(matrix, i - 1, j + 1, temp),  # Up-Right\n                dfs(matrix, i, j + 1, temp),      # Right\n                dfs(matrix, i + 1, j + 1, temp)   # Down-Right\n            )\n            \n            memo[(i, j)] = max_move\n            return max_move\n        \n        max_val = 0\n        if not grid:\n            return max_val\n        memo = {}\n        for i in range(len(grid)):\n            max_val = max(max_val, dfs(grid, i, 0, float(\'-inf\')))\n        \n        return max_val-1 \n\n```
['Array', 'Dynamic Programming', 'Matrix', 'Python']