+ 2

Challange: Remove duplicate values from an array and make a subset of this array with all unique values?

For example, we have an array {2,5,7,5,6,1,3,2,6}. Now, make an array consisting all unique values from the given array i.e. {2,5,7,6,1,3}.

28th Aug 2017, 3:55 PM
Puneet Kumar
Puneet Kumar - avatar
12 Answers
+ 12
My first challenge :) Short and simple. https://code.sololearn.com/cWr98wIuYUqj/?ref=app
30th Aug 2017, 10:16 AM
Yasar Curci
Yasar Curci - avatar
+ 9
And the winner is?
31st Aug 2017, 7:27 AM
Yasar Curci
Yasar Curci - avatar
+ 3
Here's my C# implementation ✌ LINQ One-Liner〰 Console.WriteLine(string.Join(", ", new int[] { 2, 5, 7, 5, 6, 1, 3, 2, 6 }.Distinct())); Well I think it's kinda rude here to use LINQ for this kind of challenge. Anyway, enjoy! https://code.sololearn.com/cc2SSFeuUMr3/?ref=app
28th Aug 2017, 4:13 PM
Zephyr Koo
Zephyr Koo - avatar
+ 3
@Empty that 1 minute though. 😂🙌
28th Aug 2017, 4:16 PM
Zephyr Koo
Zephyr Koo - avatar
+ 3
@Empty Really?? I just started to take up Python and let's see if I find something intersting!! 😄
28th Aug 2017, 4:56 PM
Zephyr Koo
Zephyr Koo - avatar
+ 2
For Python, I think "set" will do the trick.
28th Aug 2017, 5:08 PM
Paul
Paul - avatar
28th Aug 2017, 4:14 PM
Î‘Î·Ï„ÎżÎčπe
Î‘Î·Ï„ÎżÎčπe - avatar
+ 1
Here you go. Checks for valid input. https://code.sololearn.com/cB0X3ywupkru/?ref=app
28th Aug 2017, 5:34 PM
Vari93
Vari93 - avatar
+ 1
reusing challenges, I do a filter in https://code.sololearn.com/WaFXqRzaA6aw/?ref=app
28th Aug 2017, 9:14 PM
ysraelcon
ysraelcon - avatar
+ 1
@Yash I fixed the bug, thank you for telling it
30th Aug 2017, 10:15 AM
Î‘Î·Ï„ÎżÎčπe
Î‘Î·Ï„ÎżÎčπe - avatar
0
There are many ways to do this,the naive way is use two pointers, do loops to check every single number in array;you can also use HashSet, which is used to remove duplicate elements in the industry field.
4th Sep 2017, 4:15 PM
Ran
Ran - avatar
- 1
TRY THIS BRAND NEW CHALLENGE AND GET FRESH.. https://www.sololearn.com/discuss/666260/?ref=app
28th Aug 2017, 5:42 PM
sayan chandra
sayan chandra - avatar