DEV Community

Paolo Ventura
Paolo Ventura

Posted on • Edited on

100 algos in 100 days (Day 3)

The stolen breakfast drone

i.e. find-unique-int-among-duplicates

Struggling a bit today given quite a busy work day learning about azure blobs and functions... but no excuses!

Brute Force (o(n))
Add the integers to a set.

If the set has it already = it is a duplicate => remove it. Will be left with the sole unique.

How can you do this with bit manipulation? The answer is using XOR - super cool!
^=
This allows for o(1)

Top comments (0)