Online Python Compiler (Interpreter) - Programiz

PHOTO EMBED

Tue Jan 21 2025 12:22:26 GMT+0000 (Coordinated Universal Time)

Saved by @Narendra

def dupbit(arr):
    bitmap =0
    dup =[]
    for num in arr:
        bit= 1<<(num-1)
        if bit & bitmap:
            dup.append(num)
        else:
            bitmap |=bit
            
    return dup
    
    
    
array = [1,2,3,4,5,2,4,5,2,4,8]
print(dupbit(array))
content_copyCOPY

https://www.programiz.com/python-programming/online-compiler/