Mouses and holes problem

http://www.careercup.com/question?id=5146233651855360

Mice and holes are placed in a straight line. There are n holes on this
line. Each hole can accomodate only 1 mouse. 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.

for example if there are 3 mice positions of mice are:
4 -4 2
positions of holes are:
4 0 5

the answer should be 4
because:
Assign mouse at position x=4 to hole at position x=4 : Time taken is 0
minutes
Assign mouse at postion x=-4 to hole at position x=0 : Time taken is 4
minutes
Assign mouse at postion x=2 to hole at postion x=5 : Time taken is 3
minutes
After 4 minutes all of the mice are in the holes.
- Selfies on September 13, 2014 in - Report Duplicate | Flag