Grokking Graph Algorithms for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
Solution: Path With Minimum Effort
On this page

Problem Statement

You are given a 2D grid of size n x n containing integers, where each value grid[i][j] represents the elevation at that point (i, j).

The rain starts to fall. At time t, the depth of the water everywhere is t, and you can swim from a square to another 4-directionally adjacent square if and only if the elevation of both squares individually are at most t. You can swim infinite distances in zero time.

A route's effort is the maximum absolute difference in heights between two consecutive cells of the route.

.....

.....

.....

Like the course? Get enrolled and start learning!

On this page