逆转字符串Reverse String
2016-06-23 11:20
204 查看
https://leetcode.com/problems/reverse-string/
class Solution { public: string reverseString(string s) { int len = s.size(); if (len <= 1){ return s; } int i = 0, j = len - 1; while (i < j){ swap(s[i], s[j]); i++; j--; } return s; } };
相关文章推荐
- FLUSH TABLES WITH READ LOCK 和 LOCK TABLES的区别
- GreenDao的使用详解
- RxJava 学习笔记(一)
- 凸优化
- 十个值得一试的开源深度学习框架
- c#检查网络文件是否存在
- Centos安装(更新)git(亲测有效)
- 并查集
- java 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下矩阵: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 则依次打印出数字1,2,
- ubuntu 源仓库说明
- 获取远程访问用户的Ip地址
- tomcat服务中内存相关的优化
- iOS 微信右上角下拉菜单效果之CMPopTipView,各种角度各种位置
- Jenkins 持续集成平台构建之使用nexus搭建maven私有仓库
- 圆形指示器radialIndicator控件的使用
- Android网络框架Volley
- Leetcode no. 72
- 线段树
- android-Building Accessibility Services
- Android中dip、dp、sp、pt和px