Retired
Remove Duplicates (retired)
1,894 of 6,723richardhsu
Description:
Remove Duplicates
You are to write a function called unique
that takes an array of integers and returns the array with duplicates removed. It must return the values in the same order as first seen in the given array. Thus no sorting should be done, if 52 appears before 10 in the given array then it should also be that 52 appears before 10 in the returned array.
Assumptions
- All values given are integers (they can be positive or negative).
- You are given an array but it may be empty.
- They array may have duplicates or it may not.
Example
puts unique([1, 5, 2, 0, 2, -3, 1, 10]).inspect
[1, 5, 2, 0, -3, 10]
puts unique([]).inspect
[]
puts unique([5, 2, 1, 3]).inspect
[5, 2, 1, 3]
Arrays
Fundamentals
Similar Kata:
Stats:
Created | Aug 7, 2014 |
Warriors Trained | 11994 |
Total Skips | 1796 |
Total Code Submissions | 21186 |
Total Times Completed | 6723 |
Ruby Completions | 1894 |
CoffeeScript Completions | 209 |
Java Completions | 2502 |
Haskell Completions | 363 |
Python Completions | 1936 |
C# Completions | 243 |
Lua Completions | 9 |
Total Stars | 121 |
% of votes with a positive feedback rating | 91% of 608 |
Total "Very Satisfied" Votes | 511 |
Total "Somewhat Satisfied" Votes | 81 |
Total "Not Satisfied" Votes | 16 |