Write the code to reverse a string.
Anónimo
void reverseString(char *str) { int i=0; int j=strlen(str)-1; char temp; while(i<=j) { temp = str[i]; str[i] = str[j]; str[j] = temp; i++; j--; } } This is an O(n) operation.. linear time. just exchange first and last terms and keep moving to the middle.