Easiest solution with detailed comment in code | beat 100% |
Child 1 (Diagonal Fruits): Sum up the fruits along the main diagonal as the first child has a fixed path.  \n2. Child 2 (Top-Right to Bottom-Right): Use a DP ta
1. **Child 1 (Diagonal Fruits):** Sum up the fruits along the main diagonal as the first child has a fixed path.  \n2. **Child 2 (Top-Right to Bottom-Right):** Use a DP table to calculate the maximum fruits collected by considering transitions from possible previous cells (`down-left`, `down`, and `down-right`).  \n3. **Child 3 (Bottom-Left to Bottom-Right):** Similarly, use DP to calculate the maximum fruits collected by considering transitions from possible previous cells (`up-right`, `right`, and `down-right`). Add results to diagonal fruits.\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int maxCollectedFruits(vector<vector<int>>& fruits) {\n        int n = fruits.size();\n        // We could easily see that 1st child only could go diagonal so we compute it first\n        int ans = 0; \n        for (int i = 0; i < n; i++) ans += fruits[i][i];\n\n        vector<vector<int>>dp(n, vector<int>(n, INT_MIN));\n        // dp table for storing max fruits acquired.\n        // Compute the maximum fruits for the child starting at (0, n-1)\n        dp[0][n - 1] = fruits[0][n -1];\n        for (int i = 1; i < n; i++){ \n            for (int j = i + 1; j < n; j++) {\n                dp[i][j] = max(dp[i - 1][j - 1], dp[i - 1][j]) + fruits[i][j];\n                // if possible to move down\n                if (j + 1 < n) dp[i][j] = max(dp[i][j], dp[i - 1][j + 1] + fruits[i][j]);\n            }\n        }\n        // Compute the maximum fruits for the child starting at (n-1, 0)\n        dp[n - 1][0] = fruits[n - 1][0];\n        for (int j = 1; j < n; j++){ \n            for (int i = j + 1; i < n; i++) {\n                dp[i][j] = max(dp[i - 1][j - 1], dp[i][j - 1]) + fruits[i][j];\n                if (i + 1 < n) dp[i][j] = max(dp[i][j], dp[i + 1][j - 1] + fruits[i][j]);\n            }\n        }\n\n        return ans + dp[n - 2][n - 1] + dp[n - 1][n - 2];\n    }\n};\n```
['C++']