Easy
This one is a bit trickier than the standard interview question because of the additional requirement that you cannot allocate additional space. You must modify the array in-place with O(1) extra memory.
Still, not overly difficult though.
class Solution {
public void reverseString(char[] s) {
for (int i = 0; i < s.length / 2; i++) {
char tmp = s[s.length - i - 1];
s[s.length - i - 1] = s[i];
s[i] = tmp;
}
}
}