Leetcode 344) Reverse String
in Algorithms
https://leetcode.com/problems/reverse-string/
Follow up: Do not allocate extra space for another array. You must do this by modifying the input array in-place with O(1)
extra memory.
class Solution {
public void reverseString(char[] s) {
char tmp;
int start=0;
int end=s.length-1;
while(start<=end){
tmp = s[start];
s[start]=s[end];
s[end]=tmp;
start++;end--;
}
}
}