Find the path from bottom-left to top-right, moving only north or east, collecting the most rocks.
Unlock detailed company stats for this questionUpgrade
You are a rock collector in southern California planning a cross-country road trip to New York, with rare rocks available in cities along the way. Given a grid of numbers representing the rare rocks in each city, find the optimal path from So_Cal (start, bottom-left) to New_York (finish, top-right) that accumulates the most rocks. You can only travel north (up) or east (right). Implement optimalPath() and consider adding tests in doTestsPass(). Example: {{0,0,0,0,5},{0,1,1,1,0},{2,0,0,0,0}} gives 10 (2+0+1+1+1+0+5). Time and space complexity were also asked.
Expect follow-ups like
- What are the time and space complexities?
Format · Goldman Sachs CoderPad round, second of two questions.
Community answers
No answers contributed by the community yet.
Related questions
Given a grid of stones, find the maximum stones collected going from bottom-left to top-right moving only up or right.Find the path from the bottom-left to the top-right corner of a grid that collects the maximum points.Given two grids, find the minimum path sum from the top left to the bottom right cell where switching grids costs S.Related courses

Course

Course
Course
