1. You are given two arrays that represent positions of houses and heaters on a horizontal line. 2. Your job is to design a standard heater with fixed radius to warm all the houses. You have to find out the minimum radius of heaters so that all houses could be covered by those heaters. 3. For example, Input: houses = [1,2,3,4], heaters = [1,4] Output: 1 Explanation: The two heaters are placed in the positions 1 and 4. We need to use radius 1 standard, then all the houses can be warmed. Note: 1. main takes input from the users. 2. display is a utility function that displays an array. Feel free to use it for debugging purposes. 3. This is a functional problem. 4. You have to complete the function findRadius. It takes as input arrays houses and heaters. It should return minimum radius standard of heaters.
Input Format
First line takes input N, the length of the houses array. Second line takes input N space separated integers representing the elements of the houses array. Third line takes input M, the length of the heaters array. Fourth line takes input M space separated integers representing the elements of the heaters array. Input is handled for you.
Output Format
The minimum radius. Output is handled for you.
Constraints
1. Numbers of houses and heaters you are given are non-negative and will not exceed 25000. 2. Positions of houses and heaters you are given are non-negative and will not exceed 10^9. 3. As long as a house is in the heaters' warm radius range, it can be warmed. 4. All the heaters follow your radius standard and the warm radius will the same.
Notice
Try First, Check Solution later
1. You should first read the question and watch the question video.2. Think of a solution approach, then try and submit the question on editor tab.3. We strongly advise you to watch the solution video for prescribed approach.Example
Input
4 1 2 3 4 2 1 4
Output
1