Recursion + Memoization. Beginner's friendly code 100% beats
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\nvector<vector<int>>t;\nint solve(int i,int j,vector<vector<int>>&fruits){\n    \n    if(i>=fruits.size()||i<0||j>=fruits.size()||j<0||i>=j)\n    {\n        return 0;\n    }\n    if(t[i][j]!=-1)\n    {\n        return t[i][j];\n    }\n    int leftd=fruits[i][j]+solve(i+1,j-1,fruits);\n    int rightd=fruits[i][j]+solve(i+1,j+1,fruits);\n    int down=fruits[i][j]+solve(i+1,j,fruits);\n    return t[i][j]=max(leftd,max(rightd,down));\n}\nint solve2(int i,int j,vector<vector<int>>&fruits){\n    \n    if(i>=fruits.size()||i<0||j>=fruits.size()||j<0||i<=j)\n    {\n        return 0;\n    }\n    if(t[i][j]!=-1)\n    {\n        return t[i][j];\n    }\n    int upd=fruits[i][j]+solve2(i-1,j+1,fruits);\n    int right=fruits[i][j]+solve2(i,j+1,fruits);\n    int downd=fruits[i][j]+solve2(i+1,j+1,fruits);\n    return t[i][j]=max(upd,max(right,downd));\n}\n    int maxCollectedFruits(vector<vector<int>>&fruits){\n        int n=fruits.size();\n        int moves=n-1;\n        //for first child\n        int ans=0;\n        for(int i=0;i<n;i++)\n        {\n            for(int j=0;j<n;j++)\n            {\n                if(i==j)\n                {\n                    ans+=fruits[i][j];\n                }\n            }\n        }\n        t=vector<vector<int>>(n+1,vector<int>(n+1,-1));\n        ans+=solve(0,n-1,fruits);\n        moves=n-1;\n        t=vector<vector<int>>(n+1,vector<int>(n+1,-1));\n        ans+=solve2(n-1,0,fruits);\n        return ans;\n    }\n};\n```
['C++']