ReverseString [source code]
public class ReverseString {
public String reverseString(String s) {
String result = "";
for (int i = 0; i < s.length(); i++ ){
result += s.charAt(s.length()-1-i);
}
return result;
}
}
这个版本的有一个特别长的 testcase 超时,没有过;
Problem Description
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".