Read it. Write it. Check it.
Work through 6 original coding questions in 2 groups. Your drafts and solved status stay in this browser.
Try “Keep unique values” in the focused browser IDE · Review questions you keep missing
Loading practice progress.
0 of 6 solvedLoading device progress
easynew
Keep unique values
Return the values that appear in the input, keeping only their first appearance. Preserve the original order.
Examples
- Input
- [[4,2,4,1,2]]
- Expected
- [4,2,1]
- Input
- [[3,1,8]]
- Expected
- [3,1,8]
Constraints
- The input contains at most 10,000 finite numbers.
- Do not sort the input.
- Return a new array.
unique-values.tsSolution.uniqueValues() · browser sandboxCode editor. Tab accepts an open suggestion or indents; Shift plus Tab outdents. Press Escape, then Tab, to leave the editor. Press Command or Control plus Enter to check; add Shift to run examples.
View example solution
Compare the approach with your draft. Opening this reference does not replace your code or update progress.
Read-only code example. Use the arrow keys to navigate the code. Press Escape, then Tab, to leave the code example.
Run the examples for a quick pass, or check the full solution to record progress.