‘POINTS = [ [3, 1], [-1, 3], [2, 0] ]’, ‘N = 3’
The path with minimum time is: ‘[3,1] -> [2,2] -> [1,3] - > [0,3] -> [-1,3] -> [0,2] -> [1,1] -> [2,0]’.
Time taken from [3,1] to [-1,3] = 4 seconds.
Time taken from [-1,3] to [2,0] = 3 seconds.
Total time = 7 seconds. Thus, you should return ‘7’ as the answer.
The first line of input contains an integer ‘T’ which denotes the number of test cases. Then, the ‘T’ test cases follow.
The first line of each test case contains an integer ‘N’ denoting the number of points. Then, ‘N’ lines follow.
Each line contains two integers, ‘X’ and ‘Y’, representing an element of the array ‘POINTS’.
For every test case, the minimum time to visit all the points in the given order.
You do not need to print anything; it has already been taken care of. Just implement the function.
1 <= T <= 100
1 <= N <= 1000
Each element of ‘POINTS’ contains exactly two integers ranging from [-10^5, 10^5].
Time limit: 1 second
Longest Subarray With Zero Sum
Merge Two Sorted Arrays Without Extra Space
Ninja And The Strictly Increasing Array
Maximize
Negative To The End