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:
- An integer ‘N’ indicating the number of obstacles.
- 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
1d
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!
Add answer anonymously...
Top Deutsche Bank Software Developer interview questions & answers
Popular interview questions of Software Developer
>
Deutsche Bank Software Developer Interview Questions
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