Min Jumps Problem Statement
In Ninja town, represented as an N * M
grid, people travel by jumping over buildings in the grid's cells. Santa is starting at cell (0, 0) and must deliver gifts to cell (N-1, M-1) on Christmas Eve. Help Santa find the quickest path to deliver gifts with the least travel time.
From any cell (x, y)
, Santa can jump to (x+1, y+1)
, (x+1, y)
, or (x, y+1)
, as long as he stays within the grid boundaries. The travel time between two buildings equals the absolute difference in their heights.
Example:
Input:
T = 1
N = 3, M = 3
grid = [[1, 3, 5], [2, 8, 0], [4, 7, 6]]
Output:
7
Explanation:
One optimal path could be from (0, 0) -> (0, 1) -> (1, 2) -> (2, 2).
Constraints:
1 <= T <= 10^2
1 <= N <= 10^2
1 <= M <= 10^2
1 <= Height <= 10^5
Time Limit: 1 second
Santa needs to find the quickest path to deliver gifts in Ninja town by jumping over buildings with least travel time.
Santa starts at (0, 0) and needs to reach (N-1, M-1) on Christmas Eve.
Santa can ju...read more
Top Tata CLiQ Software Developer interview questions & answers
Popular interview questions of Software Developer
Reviews
Interviews
Salaries
Users/Month