Interview Question

Software Engineer Embedded Systems Interview

-Singapore

Gemalto

How to swap 2 variables without using a third variable. And the team leader asked to write a code snippet for assigning 5 colors to the countries on the world map so that no adjacent country has same color.

AnswerAdd Tags

Interview Answers

2 Answers

0

Use XOR

Anonymous on

5

x = x + y; y = x - y; x = x - y;

Anonymous on

Add Answers or Comments

To comment on this, Sign In or Sign Up.