Lonely Integer

  • + 0 comments

    Python solution using dictionary instead of Counter method

    def lonelyinteger(a):
        count = {}
        for i in a:
            if i in count:
                count[i] += 1
            else:
                count[i] = 1
        
        out = [ele for ele in count.keys() if count[ele] == 1][0]
        return out