标签:函数 har 示例 build 描述 hello https null uil
题目描述
示例
Code
Java
class Solution {
public String reverseString(String s) {
if (s == null || s.length() <= 1) {
return s;
}
char[] arr = s.toCharArray();
int length = arr.length;
for (int i = 0; i < length / 2; i++) {
char temp = arr[i];
arr[i] = arr[length - i - 1];
arr[length - i - 1] = temp;
}
return String.valueOf(arr);
//return new StringBuilder(s).reverse().toString();
}
}
LeetCode 344. Reverse String(反转字符串)
标签:函数 har 示例 build 描述 hello https null uil
原文地址:https://www.cnblogs.com/hglibin/p/8993636.html