https://leetcode.com/problems/reverse-string/
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = “hello”, return “olleh”.
1.
char* reverseString(char* s) {int i = 0;int j = strlen(s) - 1;while(i < j) {s[i] = s[i] ^ s[j];s[j] = s[i] ^ s[j];s[i] = s[i] ^ s[j];i++;j--;}return s;
}
2.
char* reverseString(char* s) {char *start = s;char *end = s + strlen(s) - 1;for(;start < end; ++start, --end) {*start = *start ^ *end;*end = *start ^ *end;*start = *start ^ *end;}return s;
}