[LeetCode]344. Reverse String(反转字符串)
2017-03-01 00:52
465 查看
344. Reverse String
Write a function that takes a string as input and returns the string reversed.题目大意:反向输出字符串
Example:
Given s = "hello", return "olleh".
代码如下
C++ class Solution { public: string reverseString(string s) { int a = s.size()-1; string b = ""; for(int i=a;i>=0;i--) b += s[i]; return b; } };
注意:设置a是为了不用每次循环都执行s.size()-1
相关文章推荐
- LeetCode——344. Reverse String(字符串反转)
- LeetCode344——Reverse String(将字符串反转)
- LeetCode----344. Reverse String 字符串反转
- [Leetcode,python] Reverse String 反转字符串
- [Leetcode,python] Reverse String 反转字符串
- LeetCode | 344. Reverse String 字符串水题
- LeetCode 344. Reverse String(字符串翻转)
- [Leetcode,python] Reverse String 反转字符串
- 344. Reverse String 字符串反转
- 字符串- leetcode 344. Reverse String
- [Leetcode,python] Reverse String 反转字符串
- leetcode解题之344. Reverse String & 345. Reverse Vowels of a String Java版(反转字符串)
- [Leetcode,python] Reverse String 反转字符串
- 344. Reverse String (字符串反转/逆序)
- 【LeetCode】字符串反转函数的几个算法 Reverse String
- [Leetcode,python] Reverse String 反转字符串
- leetCode 344. Reverse String 字符串
- leetcode-344. Reverse String 字符串翻转,切片的用法
- LeetCode--Reverse String 反转字符串(Python)
- 字符串-leetcode 344 Reverse String