Problem statement

https://binarysearch.com/problems/Remove-Duplicate-Numbers/

Solution

Let us use counter and then check if frequency is good. I think it is not possible to do it in O(k) space and O(n) time as hint suggested, because for every number we can not know in advance if we have it more than one time.

Complexity

It is O(n) for time and space.

Code

class Solution:
    def solve(self, nums):
        cnt = Counter(nums)
        return [i for i in nums if cnt[i] == 1]