344. Reverse String
来源:互联网 发布:高晓松酒驾 知乎 编辑:程序博客网 时间:2024/05/16 13:05
Problem Statement
Write a function that takes a string as input and returns the string reversed.
Example 1:
Given s = "hello", return "olleh".
Thinking
反转单词。
Solution
class Solution { public String reverseString(String s) { char[] s1 = s.toCharArray(); int len = s1.length - 1; int hed = 0; while(hed < len){ char x = s1[hed]; s1[hed] = s1[len]; s1[len] = x; hed++;len--; } return new String(s1); }}
阅读全文
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
- 测试小故事44:客观
- bitTiger讲解:Leetcode如何刷(经验分享)
- [机器学习实战] Ubuntu 16.04 + NVIDIA 384 + OpenCV 3.1.0 + CUDA 8.0 + cuDNN 5.1 踩坑记录
- Prim和Kruskal求最小生成树
- 递归算法的时间复杂度分析
- 344. Reverse String
- Could not obtain transaction-synchronized Session for current thread
- codevs 2604 舞会邀请 tarjan
- SpringMVC重要接口(二)HandlerMethodReturnValueHandler
- 使用OpenCV进行目标检测的注意事项
- 0基础lua学习(十一)table
- (递归)逆波兰表达式
- Python字典集合数据结构深入理解
- object