9 May 2024 Shift 1 — Remove Duplicates from Array

E · easyP · Verified PYQarrays

Remove all duplicate elements from an array and print the unique elements in the order they first appeared.

Input
7
1 3 2 1 4 3 5
Output
1 3 2 4 5
Use a HashSet/dictionary to track seen elements. Add to result only if not seen before.
← 8 May 2024 Shift 2 — Prime Number CheckAlice's Verbal Kho-Kho — Digit Passing Game →
Report an issue with this question