Given an unsorted linked list, remove all duplicate values so that each value appears only once, keeping the first occurrence of each value in its original order. Achieve O(n) time using a hash set. Return the resulting list as an array.
Input: An array of node values.
Output: Array — the de-duplicated list.
Input: [1,2,1,3,2,4]
Output: [1,2,3,4]
Explanation: First occurrences kept.Input: [1,1,1,1]
Output: [1]
Explanation: All but one removed.Input: [1,2,3]
Output: [1,2,3]
Explanation: No duplicates.0<=n<=10^50<=value<=10^9