#3132

Find the Integer Added to Array II

medium · 32.9% accepted · 179 likes · top 10%

array · two pointers · sorting · enumeration

Description

You are given two integer arrays nums1 and nums2.

From nums1 two elements have been removed, and all other elements have been increased (or decreased in the case of negative) by an integer, represented by the variable x.

As a result, nums1 becomes equal to nums2. Two arrays are considered equal when they contain the same integers with the same frequencies.

Return the minimum possible integer x that achieves this equivalence.

Solution