Tap here to switch tabs
Problem
Ask
Submissions

Problem: Find the Corrupt Pair

med
30 min
Explore how to detect the corrupt pair in an unsorted array containing numbers from 1 to n with one duplicate and one missing value. Learn to apply the cyclic sort pattern to efficiently find the missing and duplicated elements. This lesson helps you understand problem-solving strategies for array corruption issues commonly encountered in coding interviews.

Statement

We are given an unsorted array, nums, with nn elements and each element is in the range [1,n][1, n] inclusive. The array originally contained all the elements from 11 to nn but due to a data error, one of the numbers is duplicated, which causes another number missing. Find and return the corrupt pair (missing, duplicated).

Constraints:

  • 2n1032 \leq n \leq 10^3
  • 11 \leq nums[i] n\leq n
Tap here to switch tabs
Problem
Ask
Submissions

Problem: Find the Corrupt Pair

med
30 min
Explore how to detect the corrupt pair in an unsorted array containing numbers from 1 to n with one duplicate and one missing value. Learn to apply the cyclic sort pattern to efficiently find the missing and duplicated elements. This lesson helps you understand problem-solving strategies for array corruption issues commonly encountered in coding interviews.

Statement

We are given an unsorted array, nums, with nn elements and each element is in the range [1,n][1, n] inclusive. The array originally contained all the elements from 11 to nn but due to a data error, one of the numbers is duplicated, which causes another number missing. Find and return the corrupt pair (missing, duplicated).

Constraints:

  • 2n1032 \leq n \leq 10^3
  • 11 \leq nums[i] n\leq n