dp_algorithms/cherry_pickup library
🍒 Cherry Pickup (DP - complex)
This implements the classical DP approach for the simplified Cherry Pickup problem on a grid where two walkers move from (0,0) to (n-1,n-1) and can pick cherries; cells with -1 are blocked. We return the maximum cherries. Contract:
- Input: List<List
- Output: int maximum cherries collectable, 0 if none.
Time Complexity: O(n^3) Space Complexity: O(n^2)
Note: To keep implementation concise we assume small n; for production use further optimizations and thorough bounds checks.
Functions
-
cherryPickup(
List< List< grid) → intint> >