Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Can you think of this problem in a backwards way ?
Imagine expanding outward from each land cell. What kind of search does that ?
Use BFS starting from all land cells in the same time.
When do you reach the furthest water cell?