On*n*n) most intuitive (need optimization)
\nclass Solution {\n        private static int getMaxAnswer(int N, int[] children1, int[] children2, int[] children3, Map<String, Integer> dp) {\n        int n 
```\nclass Solution {\n        private static int getMaxAnswer(int N, int[] children1, int[] children2, int[] children3, Map<String, Integer> dp) {\n        int n = N;\n        int maxFruits = 0;\n\n        // Extract current positions\n        int x1 = children1[0], y1 = children1[1];\n        int x2 = children2[0], y2 = children2[1];\n        int x3 = children3[0], y3 = children3[1];\n\n        // Possible moves for child 2 and child 3\n        int[] dx = {-1, 0, 1};\n        int[] dy = {-1, 0, 1};\n\n        for (int d2x : dx) {\n            int nx2 = x2 + d2x, ny2 = y2 + 1;\n\n            // Check if child 2\'s move is valid\n            if (nx2 < 0 || nx2 >= n || ny2 < 0 || ny2 >= n) continue;\n\n            for (int d3y : dy) {\n                int nx3 = x3 + 1, ny3 = y3 + d3y;\n\n                // Check if child 3\'s move is valid\n                if (nx3 < 0 || nx3 >= n || ny3 < 0 || ny3 >= n) continue;\n\n                maxFruits = Math.max(maxFruits, dp.getOrDefault(getKey(nx2,ny2,nx3,ny3), 0));\n            }\n        }\n\n        return maxFruits;\n    }\n\n    private static int calculateUniqueFruits(int[][] fruits, int[] children1, int[] children2, int[] children3) {\n        // Positions of the children\n        int x1 = children1[0], y1 = children1[1];\n        int x2 = children2[0], y2 = children2[1];\n        int x3 = children3[0], y3 = children3[1];\n\n        int uniqueFruits = 0;\n\n        // Case 1: All three children in the same cell\n        if (x1 == x2 && y1 == y2 && x1 == x3 && y1 == y3) {\n            uniqueFruits += fruits[x1][y1];\n        }\n        // Case 2: Two children in the same cell (Child1 & Child2)\n        else if (x1 == x2 && y1 == y2) {\n            uniqueFruits += fruits[x1][y1]; // Only one child collects the fruits\n            uniqueFruits += fruits[x3][y3]; // Add fruits for Child3\n        }\n        // Case 3: Two children in the same cell (Child1 & Child3)\n        else if (x1 == x3 && y1 == y3) {\n            uniqueFruits += fruits[x1][y1]; // Only one child collects the fruits\n            uniqueFruits += fruits[x2][y2]; // Add fruits for Child2\n        }\n        // Case 4: Two children in the same cell (Child2 & Child3)\n        else if (x2 == x3 && y2 == y3) {\n            uniqueFruits += fruits[x2][y2]; // Only one child collects the fruits\n            uniqueFruits += fruits[x1][y1]; // Add fruits for Child1\n        }\n        // Case 5: All three children in different cells\n        else {\n            uniqueFruits += fruits[x1][y1]; // Add fruits for Child1\n            uniqueFruits += fruits[x2][y2]; // Add fruits for Child2\n            uniqueFruits += fruits[x3][y3]; // Add fruits for Child3\n        }\n\n        return uniqueFruits;\n    }\n\n    public static String getKey(int x1, int y1, int x2, int y2){\n        return x1+"_"+y1+"_"+x2+"_"+y2;\n    }\n    \n    public static int maxCollectedFruits(int[][] fruits) {\n        int n = fruits.length;\n        Map<String, Integer> dp = new HashMap<>();\n\n        dp.put(getKey(n-1, n-1, n-1, n-1), fruits[n-1][n-1]);\n        int k = 2;\n\n        while(k <= n){\n            int[] children1 = new int[]{n-k, n-k};\n\n            for(int i=0; i<k ;i++){\n                for(int j=0; j<k; j++){\n                    int[] children2 = new int[]{n-1-i, n-k};\n                    int[] children3 = new int[]{n-k, n-1-j};\n\n                    int fruitsCount =  calculateUniqueFruits(fruits, children1, children2, children3);\n                    int tmp = getMaxAnswer(n , children1, children2, children3, dp);\n                    int maxAnswer =  fruitsCount + tmp;\n                    dp.put(getKey(children2[0], children2[1], children3[0], children3[1]), maxAnswer);\n                }\n            }\n\n            k++;\n        }\n\n        return dp.get(getKey(n-1,0,0,n-1));\n    }\n}\n```
[]