1.The end will be a minimum possible coordinate, greater than the maximum element in the given array of elements.
2.Avoiding obstacles means that we cannot stop at the given coordinates.
3.The elements may not be in sorted order.
4.The last jump can be of any unit, provided it crosses the endpoint.
The first line of input contains an integer ‘T’ denoting the number of test cases.
The next 2 * T lines represent the ‘T’ test cases.
The first line of each test case contains an integer ‘N’, denoting the number of obstacles on the straight line.
The second line of each test case contains an array 'OBSTACLES' of 'N' elements, denoting the obstacles on the straight line.
For each test case, print a single line containing a single integer denoting the minimum length of the jump to reach the end, avoiding all the obstacles.
The output of each test case will be printed in a separate line.
You don't have to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 50
1 <= N <= 1000
1 <= OBSTACLES[i] <= 10 ^ 6
Where ‘T’ is the total number of test cases, ‘N’ denotes the number of obstacles on the straight line, and ‘OBSTACLES[i]’ denotes the coordinates of obstacles on the straight line.
Time limit: 1 sec.
Take a variable ‘jumpLength’ and initialize it to 1. Let another boolean variable be ‘obstacleHit’ and initialize it to ‘true’.
Run a while loop till the value of ‘obstacleHit’ is ‘true’.
Missing Number
Longest Subarray With Zero Sum
Merge Two Sorted Arrays Without Extra Space
Ninja And The Strictly Increasing Array
Negative To The End