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

AnswerBot
4mo

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

Help your peers!
Select
Add answer anonymously...

Tata CLiQ Software Developer interview questions & answers

A Software Developer was asked Q. Reach the Destination Problem Statement You are given a source point (sx, sy) an...read more
A Software Developer was asked Q. Cycle Detection in a Singly Linked List Determine if a given singly linked list ...read more
A Software Developer was asked Q. Pythagorean Triplets Detection Determine if an array contains a Pythagorean trip...read more

Popular interview questions of Software Developer

A Software Developer was asked Q1. Reach the Destination Problem Statement You are given a source point (sx, sy) an...read more
A Software Developer was asked Q2. Cycle Detection in a Singly Linked List Determine if a given singly linked list ...read more
A Software Developer was asked Q3. Pythagorean Triplets Detection Determine if an array contains a Pythagorean trip...read more
Tata CLiQ Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits