tags:
- code
topic: List
difficulty: Intermediate
link: https://www.codewars.com/kata/54da5a58ea159efa38000836
date: 2023-12-31
Problem
Given an array of integers, find the one that appears an odd number of times.
There will always be only one integer that appears an odd number of times.Examples
[7]
should return7
, because it occurs 1 time (which is odd).
[0]
should return0
, because it occurs 1 time (which is odd).
[1,1,2]
should return2
, because it occurs 1 time (which is odd).
[0,1,0,1,0]
should return0
, because it occurs 3 times (which is odd).
[1,2,2,3,3,3,4,3,3,3,2,2,1]
should return4
, because it appears 1 time (which is odd).
def find_it(seq):
return [i for i in set(seq) if seq.count(i) % 2 == 1][0]