> A simple one I have asked in C is to reverse the order of numbers in an array in place.
Hm...
int a[] = {1,2,3,4,5};
So, some kind of swap?
for (x = 0, y = 4; x < 5; x++, y--) {
a[x] ^= a[y]; a[y] ^= a[x]; a[x] ^= a[y];
}
See, I wouldn't mind that on a whiteboard. I had similar question for a startup, and passed easily (I think!).
But then the last question I got was 'find all word substrings in a string'. I struggled, giving a brute force answer (for each position in the string, check against dictionary and expand by one character until the end of the string), but struggled to improve on it. I didn't know about tries at the time, but even still it would be difficult for me to even try to code this on a whiteboard. Turns out it was "Google" question that was for optimizing runtime, and I cannot analyze like that on a whiteboard, unless it's obvious (nested for loops, etc.).
Anyway, after struggling and giving up with that question the next guy came in and berated me and my current employer (defense contractor). Not sure if it was because they thought I wasted their time or what. I left after that--not someone I would want to work for.