Given an integer array nums of length n where all integers are in the range [1, n] and each integer appears at most twice, return an array of all the integers that appear twice. The algorithm must run in O(n) time and use only constant auxiliary space, excluding the space needed to store the output.
Click Run to execute sample tests.