344. Reverse String
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
public class Solution {
public String reverseString(String s) {
char[] a = s.toCharArray();
int length = a.length;
char temp;
for(int i = 0; i<length/2;i++)
{
temp = a[i];
a[i] = a[length-1-i];
a[length-1-i] = temp;
}
s = String.valueOf(a);
return s;
}
}