您的位置:首页 > 其它

【LeetCode】344.Reverse String_EASY(五)

2017-04-06 22:54 441 查看
344.Reverse String

Description:

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[] word=s.toCharArray();
char[] newWord=new char[word.length];
for(int i=word.length,j=0;i>0;i--){
newWord[j]=word[i-1];
j++;
}
return new String(newWord);
}
}


完成。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: