Avoiding Traps Problem Statement

Given an array of obstacles' coordinates, determine the minimal jump length to reach beyond all obstacles starting from coordinate 0 while avoiding landing on any obstacle.

Input:

The first line gives an integer ‘T’, the number of test cases. Each test case is presented over two lines:

  1. An integer ‘N’ indicating the number of obstacles.
  2. An array named 'OBSTACLES', containing 'N' integers representing the coordinates of obstacles on the line.

Output:

For each test case, output an integer representing the minimum jump length needed to bypass all obstacles.

Example:

Input:
2
3
1 4 9
4
2 3 6 8
Output:
5
7

Constraints:

  • 1 <= T <= 50
  • 1 <= N <= 1000
  • 1 <= OBSTACLES[i] <= 10^6
Note:
  • The endpoint to aim for is any point beyond the maximum obstacle coordinate.
  • The jump length must consistently avoid all listed obstacle points.
  • Obstacles may be unsorted initially.
  • The final jump is permitted to overshoot the line's end point.
AnswerBot
4mo

Find the minimal jump length to bypass all obstacles while avoiding landing on any obstacle.

  • Iterate through the obstacle coordinates to find the maximum coordinate.

  • Calculate the minimum jump length ne...read more

Help your peers!
Select
Add answer anonymously...

Deutsche Bank Software Developer interview questions & answers

A Software Developer was asked 6mo agoQ. What are the basic definitions of OOPS?
A Software Developer was asked 8mo agoQ. Objects in java 8
A Software Developer was asked Q. Minimum Number of Operations Problem Statement Given an array 'ARR' consisting o...read more

Popular interview questions of Software Developer

A Software Developer was asked 8mo agoQ1. Objects in java 8
A Software Developer was asked Q2. Minimum Number of Operations Problem Statement Given an array 'ARR' consisting o...read more
A Software Developer was asked Q3. Reverse a String Problem Statement Given a string STR containing characters from...read more
Deutsche Bank 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