Tap here to switch tabs
Problem
Submissions

Problem: Set Mismatch

Set Mismatch gives an array containing every number from one to n, except one value appears twice and another is absent. Return the duplicate and missing values in that order.

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

Set Mismatch gives an array containing every number from one to n, except one value appears twice and another is absent. Return the duplicate and missing values in that order.

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