557. Reverse Words in a String III
static int wing=[]()
{
std::ios::sync_with_stdio(false);
cin.tie(NULL);
return ;
}(); class Solution
{
public:
string reverseWords(string s)
{
int len=s.length();
int pre=-;
auto p=s.begin();
for(int i=;i<len;i++)
{
if(s[i]==' ')
{
reverse(p+pre+,p+i);
pre=i;
}
}
reverse(p+pre+,s.end());
return s;
}
};
以空格为标志,一段一段逆置
557. Reverse Words in a String III的更多相关文章
- Leetcode#557. Reverse Words in a String III(反转字符串中的单词 III)
题目描述 给定一个字符串,你需要反转字符串中每个单词的字符顺序,同时仍保留空格和单词的初始顺序. 示例 1: 输入: "Let's take LeetCode contest" 输 ...
- leetcode 557. Reverse Words in a String III 、151. Reverse Words in a String
557. Reverse Words in a String III 最简单的把空白之间的词反转 class Solution { public: string reverseWords(string ...
- 【leetcode】557. Reverse Words in a String III
Algorithm [leetcode]557. Reverse Words in a String III https://leetcode.com/problems/reverse-words-i ...
- 557. Reverse Words in a String III【easy】
557. Reverse Words in a String III[easy] Given a string, you need to reverse the order of characters ...
- 【leetcode_easy】557. Reverse Words in a String III
problem 557. Reverse Words in a String III solution1:字符流处理类istringstream. class Solution { public: s ...
- Week4 - 500.Keyboard Row & 557.Reverse Words in a String III
500.Keyboard Row & 557.Reverse Words in a String III 500.Keyboard Row Given a List of words, ret ...
- 557. Reverse Words in a String III 翻转句子中的每一个单词
[抄题]: Given a string, you need to reverse the order of characters in each word within a sentence whi ...
- [LeetCode] 557. Reverse Words in a String III 翻转字符串中的单词 III
Given a string, you need to reverse the order of characters in each word within a sentence while sti ...
- LeetCode 557 Reverse Words in a String III 解题报告
题目要求 Given a string, you need to reverse the order of characters in each word within a sentence whil ...
- [LeetCode&Python] Problem 557. Reverse Words in a String III
Given a string, you need to reverse the order of characters in each word within a sentence while sti ...
随机推荐
- TDictionary 是delphi用的,c++builder用起来太吃力。
TDictionary 是delphi用的,c++builder用起来太吃力.c++还是用std::map代替.c++d map很好用啊.https://blog.csdn.net/ddkxddkx/ ...
- GIS on CentOS 7 之 PostgreSQL & PostGIS
PostgreSQL & PostGIS 安装postgresql 配置好yum源之后,使用yum info postgresql可发现 postgresql的版本为9.2.23,若想安装最新 ...
- 如何判断int类型相等
int a=10: int b=10: a==b 通过==判断两个int值是否相等. if(a==b){ 相等 }else{ 不相等 }
- pyplot绘图区域
pyplot绘图区域 Matplotlib图像组成 matplotlib中,整个图像为一个Figure对象,与用户交互的整个窗口 Figure对象中包含一个或多个Axes(ax)子对象,每个ax子对象 ...
- tensor flow 安装
http://blog.csdn.net/nxcxl88/article/details/52704877?locationNum=13 安装后,一定要运行这句话后 $ source activa ...
- node.js实时编译,不需要重启
npm -g install supervisor 全局安装这个,然后编译依一次文件就可以了,之后修改这个文件不用编译也可以了
- Hbase—学习笔记(一)
此文的目的: 1.重点理解Hbase的整体工作机制 2.熟悉编程api,能够用来写程序 1. 什么是HBASE 1.1. 概念特性 HBASE是一个数据库----可以提供数据的实时随机读写 HB ...
- like模糊查询
1. ${}获取值,直接连接 name like '%${search_content}%' 2.CONCAT()函数 MySQL的 CONCAT()函数用于将多个字符串连接成一个字符串,是最重要的m ...
- 域名相关:DNS A记录 NS记录 MX记录 CNAME记录
1. DNSDNS:Domain Name System 域名管理系统 域名是由圆点分开一串单词或缩写组成的,每一个域名都对应一个惟一的IP地址,这一命名的方法或这样管理域名的系统叫做域名管理系统.D ...
- Our Journey of Xian Ends
Our Journey of Xian Ends https://nanti.jisuanke.com/t/18521 262144K Life is a journey, and the roa ...