Halliburton

  www.halliburton.com
Work in HR? Unlock Free Profile

Halliburton Intern Interview Question (student candidate)

I interviewed in Houston, TX and was asked:
"Brain Teaser: Swap two numbers without using a temporary third variable."
Add Tags [?]
Answer

Part of a Intern Interview Review - one of 337 Halliburton Interview Reviews

Answers & Comments

0
of 1
vote

I provided a solution involving using multiplication/division to store the information about both numbers in a single variable

- Interview Candidate on Oct 21, 2012
1
of 2
votes

Example: A=5, B=7
B=B*A^2=7*25
A=B/(A^2)=7*25/25=7
B=sqrt(B/A)=sqrt(7*25/7)=5

- Anonymous on Nov 6, 2012
0
of 0
votes

a = a+ b
b = a - b
a = a-b

- Syed Naveed on Oct 22, 2013

To comment on this question, Sign In with Facebook or Sign Up

Tags are like keywords that help categorize interview questions that have something in common.