Learn Tech Skills from Scratch @ Scaler EDGE # Assign Mice to Holes

There are `N` Mice and `N` holes are placed in a straight 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.

Example:

``````positions of mice are:
4 -4 2
positions of holes are:
4 0 5

Assign mouse at position x=4 to hole at position x=4 : Time taken is 0 minutes
Assign mouse at position x=-4 to hole at position x=0 : Time taken is 4 minutes
Assign mouse at position x=2 to hole at position x=5 : Time taken is 3 minutes
After 4 minutes all of the mice are in the holes.

Since, there is no combination possible where the last mouse's time is less than 4,
``````

Input:

``````A :  list of positions of mice
B :  list of positions of holes
``````

Output:

``````single integer value
``````

NOTE: The final answer will fit in a 32 bit signed integer.

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 doubt? Checkout Sample Codes for more details. Hints
• Hint 1
• Solution Approach
• Complete Solution
{"ft_lang_label":"__label__en","ft_lang_prob":0.8300094,"math_prob":0.9573968,"size":1185,"snap":"2020-34-2020-40","text_gpt3_token_len":306,"char_repetition_ratio":0.15410669,"word_repetition_ratio":0.017094018,"special_character_ratio":0.2565401,"punctuation_ratio":0.116981134,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.95680463,"pos_list":[0,1,2,3,4,5,6,7,8],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-10-01T04:18:58Z\",\"WARC-Record-ID\":\"<urn:uuid:f3f2c8fa-4a26-44e5-baa3-cc736cc1b318>\",\"Content-Length\":\"108461\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:11d83290-25a0-42c9-b480-fc4225eb8fba>\",\"WARC-Concurrent-To\":\"<urn:uuid:e749c8b1-bdd3-4c24-830c-391c4f707cf1>\",\"WARC-IP-Address\":\"35.167.187.131\",\"WARC-Target-URI\":\"https://www.interviewbit.com/problems/assign-mice-to-holes/\",\"WARC-Payload-Digest\":\"sha1:WKEY6FUDAASIKHVL2OLIKZGZGPSQB2FQ\",\"WARC-Block-Digest\":\"sha1:U6W3KL34VDCQK57BPE32R3UT4HMUH2V7\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-40/CC-MAIN-2020-40_segments_1600402130615.94_warc_CC-MAIN-20201001030529-20201001060529-00235.warc.gz\"}"}