Problem Description
There are N Mice and N holes that are placed in a straight line. Each hole can accomodate only 1 mouse.
The positions of Mice are denoted by array A and the position of holes are denoted by array B.
A mouse can stay at his position, move one step right from x to x + 1, or move one step left from x to x − 1. Any of these moves consumes 1 minute.
Assign mice to holes so that the time when the last mouse gets inside a hole is minimized.
1 <= N <= 105
-109 <= A[i], B[i] <= 109
First argument is an integer array A.
Second argument is an integer array B.
Return an integer denoting the minimum time when the last nouse gets inside the holes.
Input 1:
A = [-4, 2, 3] B = [0, -2, 4]
Input 2:
A = [-2] B = [-6]
Output 1:
2
Output 2:
4
Explanation 1:
Assign the mouse at position (-4 to -2), (2 to 0) and (3 to 4). The number of moves required will be 2, 2 and 1 respectively. So, the time taken will be 2.
Explanation 2:
Assign the mouse at position -2 to -6. The number of moves required will be 4. So, the time taken will be 4.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.