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) {
if (s == null || s.length == 0)
return "";
StringBuilder builder = new StringBuilder();
char[] word = s.toCharArray();
for (int i = s.length()-1; i >= 0; i--) {
builder.append(word[i]);
}
return builder.toString();
}
}
`