😎 Challenge: Find The Chosen One! 😎 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 16

😎 Challenge: Find The Chosen One! 😎

We have an array (or list) with at least 3 elements in it. All elements are equal, except for one. Use whatever language you want to find that unique element! Some example arrays/lists (you can make your own, and as many as you want) and their respective results: [1, 1, 1, 2, 1, 1] -> 2 [2, 2, 5, 2, 2, 2, 2, 2, 2] -> 5 [0, 0, 0.55, 0, 0] -> 0.55 ["hello", "hello", "hello", "hello", "world", "hello"] -> "world" ["sololearn", 4, 4, 4, 4] -> "sololearn" Happy coding!

18th Sep 2017, 6:59 AM
noobcøder
noobcøder - avatar
17 Answers
+ 12
Sorry for being late to the party! Here's my C# implementation ✌ LINQ One-Liner〰 arr.GroupBy(o => o.ToString()) .Single(g => g.Count() == 1) .Single() I devoted myself to use LINQ to my fullest extent. ❤ Enjoy! https://code.sololearn.com/cH3Zf78C9mJc/?ref=app
18th Sep 2017, 1:07 PM
Zephyr Koo
Zephyr Koo - avatar
+ 12
https://code.sololearn.com/cNipRkRqHaPE/#java My implementation in Java!
18th Sep 2017, 11:45 PM
Vukan
Vukan - avatar
+ 7
My try in Python, and my first challenge in SL! 🤗 https://code.sololearn.com/cL6J0YqYq3wH/?ref=app
18th Sep 2017, 8:11 AM
Hikikomori
Hikikomori - avatar
24th Sep 2017, 12:53 PM
FIREmonger
FIREmonger - avatar
+ 5
https://code.sololearn.com/WFCs96q31mFU/#js
18th Sep 2017, 7:51 AM
Calviղ
Calviղ - avatar
+ 5
well, here mine, practicing on python, three-line style :) https://code.sololearn.com/cu9i6Fo8UbXL/?ref=app
18th Sep 2017, 3:30 PM
ysraelcon
ysraelcon - avatar
+ 5
https://code.sololearn.com/cUnHFGzBqJvC/?ref=app My lazy one :P
24th Sep 2017, 12:55 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 5
@$Vengat lol
24th Sep 2017, 12:59 PM
FIREmonger
FIREmonger - avatar
+ 5
4th Oct 2017, 9:28 PM
FIREmonger
FIREmonger - avatar
+ 4
nice challenge, I will do it later...
18th Sep 2017, 7:26 AM
Luca
Luca - avatar
18th Sep 2017, 8:38 AM
Sergej Schelle
Sergej Schelle - avatar
+ 4
That's damn hardcoded
24th Sep 2017, 12:54 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 4
You can make it a one-liner too
24th Sep 2017, 2:20 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 3
Will do
18th Sep 2017, 7:24 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 3
One line...Can also find element present p times https://code.sololearn.com/c9Yb1Otvo5GW/?ref=app
18th Sep 2017, 4:02 PM
VcC
VcC - avatar
+ 3
implementation in c++ (working except for lists/vecs with different element types... not handy in c++ keywords boost any etc...) https://code.sololearn.com/cL1b4YaSfuU5/?ref=app
19th Sep 2017, 1:04 PM
---
--- - avatar
+ 3
will find it
23rd Sep 2017, 11:52 PM
FIREmonger
FIREmonger - avatar