Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. module Solution
  3. def remove_duplicates(arr)
  4. return arr.length if arr.length <= 1
  5. i = 1
  6. count = 1
  7. while i < arr.length do
  8. if arr[i] != arr[i-1]
  9. arr[count] = arr[i]
  10. count = count + 1
  11. else
  12. i = i + 1
  13. end
  14. end
  15. count
  16. end
  17. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement