leetcode 344 Reverse String
来源:互联网 发布:java startwith 正则 编辑:程序博客网 时间:2024/05/29 19:20
1. 题目分析
题目描述:Write a function that takes a string as input and returns the string reversed.
Example: Given s = “hello”, return “olleh”.
题目含义:反转字符串
题目分析:从后之前取原串的元素并赋给新串即可。
2. 题目解答
class Solution {public: string reverseString(string s) { if (s.size() == 0) { return ""; } string newstr; for (int i = s.size()-1; i >= 0; --i) { newstr += s[i]; } return newstr; }};
3. 心得体会
在对串进行遍历时,注意 i 的取值范围。
阅读全文
0 0
- #leetcode# 344 Reverse String
- Leetcode Reverse String 344
- LeetCode 344 Reverse String
- LeetCode 344 Reverse String
- LeetCode 344 Reverse String
- [leetcode 344]Reverse String
- LeetCode 344:Reverse String
- leetcode 344 Reverse String
- LeetCode-344 Reverse String
- leetcode 344 Reverse String
- leetcode 344 Reverse String
- LeetCode-344:Reverse String
- LeetCode 344 Reverse String
- LeetCode#344 Reverse String
- Leetcode-344-Reverse String
- Leetcode #344 Reverse String
- leetcode-344- Reverse String
- Leetcode 344 Reverse String
- odata NextLink TotalCount 不工作
- 测试题
- cookies工具类
- WIN10 PHPSTUDY 2016 链接SQLSERVER 2008故障解决
- 二叉树的最大深度-LintCode
- leetcode 344 Reverse String
- vue.js+element ui学习笔记
- 暑假快速学习JavaScript的学习笔记
- xUtils遇到界面点击无效的bug
- 从 FingBugs的错误来看JAVA代码质量(三)
- 调研tcp定时器
- 数据挖掘几种常见损失函数
- graph_tool MacOS 安装与配置
- 序列化类型为“System.Reflection.RuntimeModule”的对象时检测到循环引用