Search
⌘K

Leetcode 741. Cherry Pickup

Given an n×n grid with cherries (1), empty cells (0) and thorns (-1), find the maximum cherries collectible by going from (0,0) to (n-1,n-1) moving only right/down and then returning moving only left/up, where cherries are picked once and thorns block traversal. The core challenge is handling the round-trip overlap—typically modeled as two simultaneous forward paths (or DP over step and two positions) to maximize cherries without double-counting and while avoiding blocked cells.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.