Domanda di colloquio di P\S\L Group

Swap the value of two variables without any third variable.

Risposta di colloquio

Anonimo

9 ago 2018

Imagine x=10 and Y=6. Compare which is bigger. Then iterate x-y=4 times adding one to small number and substracting one to the big number. So x-4=6 and y+4=10.