Solutions for non-duplicated integer

    • @JavierVow
    • @jacob, submitted in Python 2, achived 100% score
    WORD_SIZE = 32
    
    
    def solve(arr):
        non_duplicate = 0
    
        for i in range(0, WORD_SIZE):
            sum_i_position_bits = 0
            x = 1 << i
            for j in range(len(arr)):
                if arr[j] & x:
                    sum_i_position_bits += 1
    
            if sum_i_position_bits % 3:
                non_duplicate |= x
    
        return non_duplicate
    • @JavierVow
    • @jacob, submitted in Python 3, achived 100% score
    WORD_SIZE = 32
    
    
    def solve(arr):
        non_duplicate = 0
    
        for i in range(0, WORD_SIZE):
            sum_i_position_bits = 0
            x = 1 << i
            for j in range(len(arr)):
                if arr[j] & x:
                    sum_i_position_bits += 1
    
            if sum_i_position_bits % 3:
                non_duplicate |= x
    
        return non_duplicate