344. Reverse String
来源:互联网 发布:php打印前一天时间 编辑:程序博客网 时间:2024/05/21 06:53
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
Subscribe to see which companies asked this question
Example:
Given s = "hello", return "olleh".
Subscribe to see which companies asked this question
public class Solution {
public String reverseString(String s) {
if(s==null || s.length()==0){
return s;
}
int left = 0;
int right = s.length()-1;
char[] sChar = s.toCharArray();
while(left<right){
char temp = sChar[left];
sChar[left] = sChar[right];
sChar[right] = temp;
left++;
right--;
}
return new String(sChar);
}
}
0 0
- String:344. Reverse String
- 344.Reverse String(String-Easy)
- leetcode--344. Reverse String
- 344. Reverse String
- 344. Reverse String [E]
- LeetCode 344. Reverse String
- 344. Reverse String
- LeetCode 344. Reverse String
- 344. Reverse String
- 344. Reverse String
- 344. Reverse String
- Leetcode:344. Reverse String
- 344. Reverse String
- LeetCode *** 344. Reverse String
- 344. Reverse String
- LeetCode *** 344. Reverse String
- 344. Reverse String
- [leetcode] 344. Reverse String
- 单链表反转
- 要么读书,要么健身,要么恋爱(六)解忧杂货铺
- 哈希表存储效率50%的原因
- 关于ubuntu 16.04和fedora 24的安装eclipse c/c++过程
- 数通开发必备工具
- 344. Reverse String
- SpringMVC使用@Valid注解进行数据验证
- DOS 常用命令
- 文章标题 poj 1837: Balance(dp)
- ubuntu pycharm安装(.sh文件安装)与配置
- linux随笔
- 五音不全中,五音是指什么
- 要么读书,要么健身,要么恋爱(六)白夜行
- Live Archive 5659 The Last Puzzle