DEV Community

LeetCode in Ruby: 26. Remove Duplicates from Sorted Array

Kaitian Xie on March 19, 2019

def remove_duplicates(nums) nums.uniq! return nums.length end First, use uniq! to remove all the duplicates in nums. Then return its length...
Collapse
 
rnrnshn profile image
Olimpio

Interesting... And it's fast...