From : www.LeetCode.com
Description
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = “hello”, return “olleh”.
中文介绍
描述
给定一个字符串,返回该字符串反转后的结果。
例子
例如给一个字符串 s = “hello” ,返回 “olleh”。
解决方案一
本方案的思想:
由于题目并没有其他的限制条件,因此直接使用API来获取反转后的字符串。
代码实现(JAVA)
class Solution {
public String reverseString(String s) {
return new StringBuilder(s).reverse().toString();
}
}