Back to problems

Array Duplication — O(n) and Memory Trade-offs

Algorithm · Okta · Medium

You are given an unsorted list of integers, arr. Your task is to produce a new list containing only the unique values from the original input. The order of the unique values in the output should match their first appearance in arr. Please solve this in a way that completes in linear time and uses linear auxiliary space relative to the number of elements. Follow-up: After your initial implementation, you are asked to re-build the logic using an object-based inline computation…

Checking your access…