▲ | dahcryn a day ago | ||||||||||||||||
you are missing the most obvious one, no? Sum both lists and take the difference, that's the missing number, since the items are guaranteed unique | |||||||||||||||||
▲ | vbezhenar a day ago | parent | next [-] | ||||||||||||||||
It is interesting for me to remember my very first programming task. The very first day I was introduced to programming with Pascal (I think I was 14), I was taught variables, assignments, arithmetic and was given a task to switch two variables (swap). I quickly solved it using third variable, but then I was asked to do it without third variable. It was very hard task for me, I spent few hours at home tackling it, but finally I solved it with a trick conceptually similar to XOR:
I'm still proud of little me and I always remember this solution when I encounter XOR tricks. I didn't knew about bitwise arithmetic at that time, but sometimes simple `+` can work just as well. | |||||||||||||||||
▲ | a day ago | parent | prev | next [-] | ||||||||||||||||
[deleted] | |||||||||||||||||
▲ | zeroq a day ago | parent | prev [-] | ||||||||||||||||
overflow | |||||||||||||||||
|