9 May 2024 Shift 1 — Remove Duplicates from Array
E · easyP · Verified PYQarrays
Problem
Remove all duplicate elements from an array and print the unique elements in the order they first appeared.
Example
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.