Asked inDE Shaw,Associate Developer Intern

Jump Game Problem Statement

In this problem, you are given an array ARR consisting of N integers. Your task is to determine the minimum number of jumps required to reach the last index of the array N - 1. At any given index i, you can jump to any index between i + 1 and i + ARR[i] inclusive. The element at index i specifies the maximum distance you can jump from that index.

Input:

The input begins with an integer, T, representing the number of test cases. For each test case, the first line contains an integer N, representing the number of elements in ARR. The following line consists of N space-separated integers, which are the elements of ARR.

The first line of input contains an integer ‘T’
The first line of each test case contains an integer ‘N’
The second line of each test case contains ‘N’ space-separated integers

Output:

For each test case, output a single integer, which is the minimum number of jumps required to reach the last index. Each test case result should be printed on a new line.

For each test case, print a single line containing a single integer

Example:

Consider the following example:

Input:
T = 1
N = 6
ARR = [2, 3, 1, 1, 4, 2]

Output:
2

Explanation: Start from index 0, jump to index 1, and then directly to index 5.

Constraints:

  • 1 <= T <= 50
  • 1 <= N <= 10^4
  • 1 <= ARR[i] <= 10^4
  • Assume that you can always reach the last index.
  • Time limit: 1 sec.
Note:

All inputs are based on 0-based indexing.

Be the first one to answer
Select
Add answer anonymously...
DE Shaw Associate Developer Intern 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