Back to course home
0% completed
Vote For New Content
Easier with hashmap
sealess
Mar 6, 2024
class Solution: def remove(self, arr): # TODO: Write your code here hashmap = {} for i in arr: if i not in hashmap: hashmap[i] = 1 return len(hashmap.keys())
0
1
Comments
Comments
Kaijie Fu2 years ago
you should not use any extra space so that the solution has constant space complexity i.e.,
Sachin Dev Sa year ago
question mentions that you can't use extra space and this needs to be done in in-place.
Else we can also use set
On this page
Problem Statement
Try it yourself