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
Be the first one to answer
Add answer anonymously...
Top Tata CLiQ Software Developer interview questions & answers
Popular interview questions of Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app