Search
⌘K

Leetcode 2122. Recover the Original Array

Given a multiset of 2n numbers that are exactly the values arr[i]-k and arr[i]+k for some unknown positive k, recover arr by finding a positive k such that the numbers can be paired into n couples with difference 2k and taking each arr[i] as the midpoint of its pair — typically done by sorting and greedy multiset/counter pairing using candidate differences from the smallest element.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.