
N=10, M=3
C = [2,4,7] ( The positions of the streetlights )
R = 3 ( The range of the street-lights)
The answer will be 2 as we can install the first street light at position 2 so it illuminates the street from positions from 1 to 5 and the third street light at 7 so it illuminates the street from positions from 4 to 10.
The first line contains a single integer ‘T’ representing the number of test cases. Then each test case follows.
The first line of each test case contains two integers ‘N’ and ‘M’ denoting the length of the street and the number of street lights that are provided to you.
The next line of every test case contains ‘M’ integers ('C[i]') which denote the position of the 'ith' streetlight.
The next line of every test case contains an integer 'R' which denote the range of the street lights.
For each test case, return the minimum number of street lights required to light up the street. If it is not possible to light up the whole street, return -1.
The output of each test case should be printed in a separate line.
You are not required to print anything, it has already been taken care of. Just implement the function.
1 <= T <= 10
1 <= N <= 10^9
1 <= M <= 10^5
1 <= C[i] <= N
0 <= R <= 10^9
It is guaranteed that the sum of ‘M’ over all test cases is less than equal to 10^5.
Time Limit: 1 sec
Algorithm:
Return ‘ANS’