Search⌘ K
AI Features

Solution: Find the Corrupt Pair

Understand how to apply cyclic sort to position elements correctly in an array containing numbers from 1 to n with one duplicate and one missing. Learn to identify the corrupt pair efficiently by scanning the sorted array once, with a time complexity of O(n) and constant space usage.

Statement

We are given an unsorted array, nums, with nn elements and each element is in the range [1,n] ...