Suppose given ‘HOUSES’ is [1,2,3] and ‘NINJAS’ is [2] then
The defending radius range of the ninjas (‘NINJAS’) is 1 since there is only one ninja that is defending at position 2, and if we use the radius 1 standard, then all the houses can be protected.

The first line of input contains a single integer ‘T’ denoting the number of test cases given. Then next ‘T’ lines follow:
The first line of each test case input contains two space-separated integers, where the first integer 'N' represents the length of the ‘HOUSES’ array while the second integer 'M' represents the length of ‘NINJAS' array.
The second line of each test contains ‘N’ space-separated integers which are the elements of the position of houses (‘HOUSES’) array.
The third line of each test contains ‘M’ space-separated integers which are the elements of the position of Ninjas (‘NINJAS’) array.
For every test case, print an integer denoting the minimum radius standard of (‘NINJAS’) Ninjas so that those Ninjas could defend all houses.
1. You do not need to print anything, it has already been taken care of. Just Implement the given function.
2. Notice that all the ninjas (‘NINJAS’) follow your radius standard, and the defending radius will be the same.
1 <= T <= 10
1 <= N, M <= 3 * 10^3
1 <= HOUSES[i], NINJAS[i] <= 10^9
Where 'HOUSES[i]' represent the position of 'ith' house and 'NINJAS[i]' represent the position of 'ith' Ninja.
Time Limit: 1 sec
A possible solution could be to take each house ‘i’ (‘HOUSE’[i]) and check if it has a Ninja guarding it that is if (‘HOUSE’[i] == ‘NINJA’[i]) both have the same position. Then this house ‘i’ is already equipped with a Ninja and we can continue to evaluate the next house.
If the position of house ‘i' is smaller than all elements of the ‘NINJAS’ array, record the distance from ‘i’ to the first element of the ‘NINJAS’ array.
If the position of house ‘i’ is larger than all elements of the ‘NINJAS’ array, record the distance from ‘i’ to the last element of the ‘NINJAS’ array.
If the position of house ‘i’ in between the two adjacent elements (positions) of the ‘NINJAS’ array, calculate the distances from the left and right of ‘HOUSE’[i] respectively and take the minimum value, and only when the defending radius satisfies this value, the house ‘i’ can be covered by the defending range of the left or right Ninja. Finally, return the resultant standard radius range which can now be set for all the houses.
The algorithm to calculate the required will be:-
An efficient solution that we can use here is while traversing the array of the house, we keep calculating the nearest Ninja that would be able to defend the houses by making a binary search which can be used to find the exact index for a particular house position or -1 if it doesn't exist. We can modify binary search to yield the index of the nearest number. For our problem, this means that we would be able to find the index of the closest Ninja in O(log(M)).
The algorithm to calculate the required will be:-
Element Count in Ranges
First Digit One
Minimize Maximum Adjacent Distance
Sorted Doubly Linked List to Balanced BST
Minimized Maximum of Products Distributed to Any Store