<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>reversed Archives - Huahua&#039;s Tech Road</title>
	<atom:link href="https://zxi.mytechroad.com/blog/tag/reversed/feed/" rel="self" type="application/rss+xml" />
	<link>https://zxi.mytechroad.com/blog/tag/reversed/</link>
	<description></description>
	<lastBuildDate>Sat, 03 Mar 2018 07:53:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.0.8</generator>

<image>
	<url>https://zxi.mytechroad.com/blog/wp-content/uploads/2017/09/cropped-photo-32x32.jpg</url>
	<title>reversed Archives - Huahua&#039;s Tech Road</title>
	<link>https://zxi.mytechroad.com/blog/tag/reversed/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>花花酱 LeetCode 557 Reverse Words in a String III</title>
		<link>https://zxi.mytechroad.com/blog/string/leetcode-557-reverse-words-in-a-string-iii/</link>
					<comments>https://zxi.mytechroad.com/blog/string/leetcode-557-reverse-words-in-a-string-iii/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Sat, 03 Mar 2018 07:43:42 +0000</pubDate>
				<category><![CDATA[String]]></category>
		<category><![CDATA[reversed]]></category>
		<category><![CDATA[words]]></category>
		<guid isPermaLink="false">http://zxi.mytechroad.com/blog/?p=1925</guid>

					<description><![CDATA[<p>题目大意：独立反转字符串中的每个单词。 Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/string/leetcode-557-reverse-words-in-a-string-iii/">花花酱 LeetCode 557 Reverse Words in a String III</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>题目大意：独立反转字符串中的每个单词。</p>
<p>Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.</p>
<p><b>Example 1:</b></p><pre class="crayon-plain-tag">Input: &quot;Let's take LeetCode contest&quot;
Output: &quot;s'teL ekat edoCteeL tsetnoc&quot;</pre><p><b>Note:</b> In the string, each word is separated by single space and there will not be any extra space in the string.</p>
<p><strong>Idea: Brute Force</strong></p>
<p>C++</p><pre class="crayon-plain-tag">// Author: Huahua
// Running time: 23 ms
class Solution {
public:
  string reverseWords(string s) {    
    int index = 0;  
    for (int i = 0; i &lt;= s.length(); ++i) {
      if (i == s.length() || s[i] == ' ') {
        std::reverse(s.begin() + index, s.begin() + i);
        index = i + 1;
      }
    }
    return s;
  }
};</pre><p>&nbsp;</p>
<p>Python3</p><pre class="crayon-plain-tag">"""
Author: Huahua
Running time: 44 ms (beats 100%)
"""
class Solution:
  def reverseWords(self, s):        
    return ' '.join(map(lambda x: x[::-1], s.split(' ')))</pre><p>&nbsp;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/string/leetcode-557-reverse-words-in-a-string-iii/">花花酱 LeetCode 557 Reverse Words in a String III</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://zxi.mytechroad.com/blog/string/leetcode-557-reverse-words-in-a-string-iii/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
