We're a place where coders share, stay up-to-date and grow their careers.
Looks a bit messy, but I was going for something that might not be too inefficient with a large input array
def stray(arr): count = {} for index, i in enumerate(arr): count[i] = count.setdefault(i, 0) + 1 if index >= 2 and len(count.keys()) > 1: break return next(k for k, v in count.items() if v == 1)
Looks a bit messy, but I was going for something that might not be too inefficient with a large input array