← Questions

Longest water-flow path with momentum

0
GoogleCodingLast asked Apr 2026

You get an m x n matrix of heights. Water starts at any cell and moves to a neighboring cell up, down, left or right. Whether it may move on depends on the heights and on the momentum it has built up on earlier steps. Return the length of the longest path it can travel.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding