Facebook Interview Question: Reverse a string in-place usi... | Glassdoor

Interview Question

Software Engineer Interview Palo Alto, CA

Reverse a string in-place using C.


Interview Answer

2 Answers


reverse(char *str)
   char *end = str + strlen(str) - 1;

   while (end > str)
      char t = *str;
      *str = *end;
      *end = t;


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.