The Two Sneaky Numbers of Digitville

Digitville keeps a list nums that should hold every integer from 0 to n - 1 exactly once. Two mischievous numbers each sneaked in one extra time, so the list now has n + 2 elements. Return the two sneaky numbers as an array of size two, in any order.

30:00

The Two Sneaky Numbers of Digitville
easy
Free written solution
Topics
Companies

Digitville keeps a list nums that should hold every integer from 0 to n - 1 exactly once. Two mischievous numbers each sneaked in one extra time, so the list now has n + 2 elements. Return the two sneaky numbers as an array of size two, in any order.

Example 1:
Input: {"nums":[0,1,1,0]}
Output: [0,1]
Constraints:
  • 2≤n≤1002 \leq n \leq 100

  • nums.length=n+2\text{nums.length} = n + 2

  • 0≤nums[i]<n0 \leq \text{nums}[i] < n

  • The input has exactly two repeated elements.

Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result

Run code to see results.

Input
arr ={"nums":[0,1,1,0]}

4 numbers, but only the values 0..1 exist, so exactly two values must show up twice.

nums (4 values for 2 slots)

0
1
1
0

tally bins: count[v]

0

1

result

none yet

Variables
VariableValue
len4
n2
DepthFunction Call
Stack empty
0/11