def remove_duplicates(nums)
nums.uniq!
return nums.length
end
First, use uniq!
to remove all the duplicates in nums
. Then return its length.
Time complexity: O(n)
Extra memory: O(1)
def remove_duplicates(nums)
nums.uniq!
return nums.length
end
First, use uniq!
to remove all the duplicates in nums
. Then return its length.
Time complexity: O(n)
Extra memory: O(1)
For further actions, you may consider blocking this person and/or reporting abuse
Hey, if you're landing here for the first time, you should know that this website is a global community of folks who blog about their experiences to help folks like you out.
mhcrocky -
ZeeshanAli-0704 -
SalahElhossiny -
marskimiko -
Once suspended, algobot76 will not be able to comment or publish posts until their suspension is removed.
Once unsuspended, algobot76 will be able to comment and publish posts again.
Once unpublished, all posts by algobot76 will become hidden and only accessible to themselves.
If algobot76 is not suspended, they can still re-publish their posts from their dashboard.
Once unpublished, this post will become invisible to the public and only accessible to Kaitian Xie.
They can still re-publish the post if they are not suspended.
Thanks for keeping DEV Community π©βπ»π¨βπ» safe. Here is what you can do to flag algobot76:
Unflagging algobot76 will restore default visibility to their posts.
Top comments (1)
Interesting... And it's fast...