The Unique Sieve

HardAcc. 68.5%
+50 XP 30

Manual Deduping

How do you know if a number is new? You look back at your "seen" history.

The Assignment

Your function receives an array nums.

  1. Use an outer loop to pick a number.
  2. Use an inner loop to check if this number exists in the array at any index smaller than the current outer index.
  3. If it does NOT exist before, it is unique! Print the number.

01EXAMPLE 1

Input[1, 2, 1, 3]
Output1 2 3

Explanation: The second 1 is ignored.

Constraints

  • Use nested loops.
  • Do not use Set() or .indexOf().
ArraysLoopsMastery
JavaScript
Loading...
2 Hidden

Input Arguments

nums[1,2,1,3]

Expected Output

1
2
3

Click RUN to test your solution