Intuitive dynamic programming
first can only take diagonal or it wont reach end in n-1 moves\n2nd need to be above diagonal or on it to reach in n-1 steps\nand 3rd need to be below or on dia
first can only take diagonal or it wont reach end in n-1 moves\n2nd need to be above diagonal or on it to reach in n-1 steps\nand 3rd need to be below or on diagonal to reach\nonce you figure this you know there will be no  overlap so just give the answer\n# Code\n```python3 []\nclass Solution:\n    def maxCollectedFruits(self, fruits: List[List[int]]) -> int:\n        f1 = 0\n        n = len(fruits)\n        for i in range(n):\n            f1 += fruits[i][i]\n            fruits[i][i] = 0\n        @cache\n        def do(x, y, dirx, op):\n            if x < 0 or y < 0 or x >= n or y >= n:\n                return -float(\'inf\')\n            if (x, y) == (n-1, n-1):\n                return fruits[x][y]\n            ans = -float(\'inf\')\n            for i, j in dirx:\n                if op == 0 and not (x + i <= y + j):\n                    continue\n                elif op == 1 and not (x + i >= y + j):  \n                    continue\n                ans = max(ans, fruits[x][y] + do(x + i, y + j, dirx, op))\n            return ans\n        f2 = do(0, n - 1, ((1, -1), (1, 0), (1, 1)), 0)\n        # print(f2)\n        f3 = do(n - 1, 0, ((-1, 1), (0, 1), (1, 1)), 1)  \n        return f1 + f2 + f3\n\n```
['Dynamic Programming', 'Python3']