Tap here to switch tabs
Problem
Submissions

Problem: Set Mismatch

med
30 min
Try to solve the Set Mismatch problem.

Statement

You are given an integer array nums that originally contained all the numbers from 11 to n, where n is the length of nums. Due to an error, one number in the collection was duplicated, causing another number to be missing.

Find the number that occurs twice and the number that is missing, and return them as an array in the format [duplicate, missing].

Constraints:

  • 2≤2 \leq nums.length ≤104\leq 10^4

  • 1≤1 \leq nums[i] ≤104\leq 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Set Mismatch

med
30 min
Try to solve the Set Mismatch problem.

Statement

You are given an integer array nums that originally contained all the numbers from 11 to n, where n is the length of nums. Due to an error, one number in the collection was duplicated, causing another number to be missing.

Find the number that occurs twice and the number that is missing, and return them as an array in the format [duplicate, missing].

Constraints:

  • 2≤2 \leq nums.length ≤104\leq 10^4

  • 1≤1 \leq nums[i] ≤104\leq 10^4