Algorithm · Bloomberg · Medium
You are given an integer array nums with n elements. Every value satisfies $$1 \le nums[i] \le n$$, and each distinct integer in the array occurs either a single time or exactly two times. Return all of the integers that occur twice. Your solution must meet these requirements: It runs in $$O(n)$$ time. It uses only $$O(1)$$ additional space, not counting the list that is returned. It is allowed to change the contents of nums. The integers in the result can appear in any…