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.
- Use an outer loop to pick a number.
- Use an inner loop to check if this number exists in the array at any index smaller than the current outer index.
- If it does NOT exist before, it is unique! Print the number.
01EXAMPLE 1
Input
[1, 2, 1, 3]Output
1
2
3Explanation: The second 1 is ignored.
Constraints
- Use nested loops.
- Do not use Set() or .indexOf().
ArraysLoopsMastery
JavaScriptSystem handles I/O — write your function only
Loading...
2 Hidden
Input Arguments
nums[1,2,1,3]
Expected Output
1 2 3
Click RUN to test your solution