Skip to content

Latest commit

 

History

History
46 lines (26 loc) · 683 Bytes

Find_the_unique_number.md

File metadata and controls

46 lines (26 loc) · 683 Bytes

CodeWars Python Solutions


Find the unique number

There is an array with some numbers. All numbers are equal except for one. Try to find it!

find_uniq([ 1, 1, 1, 2, 1, 1 ]) == 2
find_uniq([ 0, 0, 0.55, 0, 0 ]) == 0.55

It’s guaranteed that array contains at least 3 numbers.

The tests contain some very huge arrays, so think about performance.


Given Code

def find_uniq(arr):
    # your code here

Solution 1

def find_uniq(arr):
    for char in set(arr):
        if arr.count(char) == 1:
            return char

See on CodeWars.com