2dbi
Home/Workday/Remove Duplicates Preserving Order
WWorkday·DSASDE-1Online Assessment

Remove Duplicates Preserving Order

Problem

Given an array, return the unique elements in their original order (no sorting).

Example

[3,1,3,4,1,5] -> [3,1,4,5]

Constraints

  • 1 ≤ n ≤ 10^5

Approach

Hash set to track seen while iterating. Reported Workday OA question.

added 6 days ago
LeadersAccount