Interview Question

Interview Palo Alto, CA

Reverse a string in-place using C.


Interview Answer

2 Answers


void reverse(char *str) { char *end = str + strlen(str) - 1; while (end > str) { char t = *str; *str = *end; *end = t; str++; end--; } }

Anonymous on Apr 15, 2010

You rated the interview as "Very Difficult", and yet the questions you posted are trivially easy and very common, was that supposed to be some sort of joke? :(

Anonymous on Oct 22, 2010

Add Answers or Comments

To comment on this, Sign In or Sign Up.