Search⌘ K
AI Features

Solution: Find the Corrupt Pair

Understand how to use cyclic sort to find the missing and duplicated numbers in an unsorted array where one number is corrupted. Explore an efficient approach that swaps elements to their correct positions and detects the corrupt pair in linear time with constant space. This lesson helps you master a key pattern useful for coding interview questions involving data errors and array manipulation.

Statement

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