Yeah, I suppose you'd need 1 temporary variable. Your solution doesn't work either, though: doing the freshman XOR trick some arbitrary fixed number of times just reduces to the XOR trick, which is plainly not what the task asked.
Here it is with a 4-element array, a[0] through a[3]:
a=[100,200,300,400]
a[0] ^= a[3]
a[3] ^= a[0]
a[0] ^= a[3]
a[1] ^= a[2]
a[2] ^= a[1]
a[1] ^= a[2]
a
[400, 300, 200, 100]
(Pretend this list is an array, it's just for illustrative purposes)http://www.lysator.liu.se/faq/c-faq/c-2.html
The general point is that interviews of this type are counterproductive.
If you want to posit any kind of sane question, then you can have a sane solution.
That's what I said a few posts ago.
> You can't claim to have a solution for the problem if it only works for a
> fixed input, and if the solution itself would be different for different
> inputs.
"Reverse this array". Done. "Reverse an unspecified array of arbitrary length" is a different problem :)