Amazon Interview Question

String reversal in place

Interview Answer

Anonymous

Oct 8, 2010

Assume that s is the string. Here is a C++ like solution: end= s.length()-1; first=0; While (first <= end) { t=s[first]; s[first] = s[end]; s[end] = t; first++; end— }

1