Practice Find the Maximum Number of Fruits Collected
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Three children start in an n by n fruit grid at (0, 0), (0, n - 1), and (n - 1, 0). Each makes exactly n - 1 moves to (n - 1, n - 1), staying inside the grid. From (r, c), the first child may move to (r + 1, c), (r, c + 1), or (r + 1, c + 1); the second to (r + 1, c - 1), (r + 1, c), or (r + 1, c + 1); and the third to (r - 1, c + 1), (r, c + 1), or (r + 1, c + 1). Visiting a room collects its fruits, but a room’s fruits count only once even if several children visit it. Return the maximum total collected.
Source: Find the Maximum Number of Fruits Collected on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
fruits = [[1,2,3,4],[5,6,8,7],[9,10,11,12],[13,14,15,16]]
100
# Example 2
fruits = [[1,1],[1,1]]
4
Constraints
Related LeetCode Problems
Practice more problems similar to Find the Maximum Number of Fruits Collected.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.