<?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>find Archives - Huahua&#039;s Tech Road</title>
	<atom:link href="https://zxi.mytechroad.com/blog/tag/find/feed/" rel="self" type="application/rss+xml" />
	<link>https://zxi.mytechroad.com/blog/tag/find/</link>
	<description></description>
	<lastBuildDate>Sun, 27 Feb 2022 05:11:07 +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>find Archives - Huahua&#039;s Tech Road</title>
	<link>https://zxi.mytechroad.com/blog/tag/find/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>花花酱 LeetCode 2185. Counting Words With a Given Prefix</title>
		<link>https://zxi.mytechroad.com/blog/string/leetcode-2185-counting-words-with-a-given-prefix/</link>
					<comments>https://zxi.mytechroad.com/blog/string/leetcode-2185-counting-words-with-a-given-prefix/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Sun, 27 Feb 2022 05:10:38 +0000</pubDate>
				<category><![CDATA[String]]></category>
		<category><![CDATA[count_if]]></category>
		<category><![CDATA[easy]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[string]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=9506</guid>

					<description><![CDATA[<p>You are given an array of strings&#160;words&#160;and a string&#160;pref. Return&#160;the number of strings in&#160;words&#160;that contain&#160;pref&#160;as a&#160;prefix. A&#160;prefix&#160;of a string&#160;s&#160;is any leading contiguous substring of&#160;s. Example&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/string/leetcode-2185-counting-words-with-a-given-prefix/">花花酱 LeetCode 2185. Counting Words With a Given Prefix</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>You are given an array of strings&nbsp;<code>words</code>&nbsp;and a string&nbsp;<code>pref</code>.</p>



<p>Return&nbsp;<em>the number of strings in&nbsp;</em><code>words</code><em>&nbsp;that contain&nbsp;</em><code>pref</code><em>&nbsp;as a&nbsp;<strong>prefix</strong></em>.</p>



<p>A&nbsp;<strong>prefix</strong>&nbsp;of a string&nbsp;<code>s</code>&nbsp;is any leading contiguous substring of&nbsp;<code>s</code>.</p>



<p><strong>Example 1:</strong></p>



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> words = ["pay","<strong><u>at</u></strong>tention","practice","<strong>at</strong>tend"], <code>pref </code>= "at"
<strong>Output:</strong> 2
<strong>Explanation:</strong> The 2 strings that contain "at" as a prefix are: "<strong>at</strong>tention" and "<strong>at</strong>tend".
</pre>



<p><strong>Example 2:</strong></p>



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> words = ["leetcode","win","loops","success"], <code>pref </code>= "code"
<strong>Output:</strong> 0
<strong>Explanation:</strong> There are no strings that contain "code" as a prefix.
</pre>



<p><strong>Constraints:</strong></p>



<ul><li><code>1 &lt;= words.length &lt;= 100</code></li><li><code>1 &lt;= words[i].length, pref.length &lt;= 100</code></li><li><code>words[i]</code>&nbsp;and&nbsp;<code>pref</code>&nbsp;consist of lowercase English letters.</li></ul>



<h2><strong>Solution: Straight forward </strong></h2>



<p>We can use std::count_if and std::string::find.</p>



<p>Time complexity: O(n*l)<br>Space complexity: O(1)</p>



<div class="responsive-tabs">
<h2 class="tabtitle">C++</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag">// Author: Huahua
class Solution {
public:
  int prefixCount(vector&lt;string&gt;&amp; words, string pref) {
    return count_if(begin(words), end(words), [&amp;](const string&amp; w) {
      return w.find(pref) == 0;
    });
  }
};</pre>
</div></div>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/string/leetcode-2185-counting-words-with-a-given-prefix/">花花酱 LeetCode 2185. Counting Words With a Given Prefix</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-2185-counting-words-with-a-given-prefix/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>玩转Linux命令行 &#8211; 事件处理 &#8211; EP3</title>
		<link>https://zxi.mytechroad.com/blog/linux/linux-cmd-event-processing-ep3/</link>
					<comments>https://zxi.mytechroad.com/blog/linux/linux-cmd-event-processing-ep3/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Fri, 08 May 2020 07:40:47 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[command-line]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[sort]]></category>
		<category><![CDATA[uniq]]></category>
		<category><![CDATA[xargs]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=6713</guid>

					<description><![CDATA[<p>Download Data [crayon-6665e78894220962856902/] [crayon-6665e78894223890808804/] [crayon-6665e78894224571742597/] [crayon-6665e78894225525352977/]</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/linux/linux-cmd-event-processing-ep3/">玩转Linux命令行 &#8211; 事件处理 &#8211; EP3</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="玩转Linux命令行 - 事件处理 - EP3" width="500" height="375" src="https://www.youtube.com/embed/TWwvJw6UoxY?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div></figure>



<h2><strong>Download Data</strong></h2>



<div class="responsive-tabs">
<h2 class="tabtitle">download.sh</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag">for i in $(seq -w 01 80)
do  
  curl -O -J https://raw.githubusercontent.com/rozim/ChessData/master/mega2400_part_${i}.pgn
done</pre>
</div></div>



<div class="responsive-tabs">
<h2 class="tabtitle">V1</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag">cat *.pgn | grep &quot;Result&quot; | sort | uniq -c</pre>
</div></div>



<div class="responsive-tabs">
<h2 class="tabtitle">V2</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag">cat *.pgn | grep &quot;Result&quot; | awk '{ split($0, a, &quot;-&quot;); res = substr(a[1], length(a[1]), 1); if (res == 1) white++; if (res == 0) black++; if (res == 2) draw++;} END { print white+black+draw, white, black, draw }'</pre>
</div></div>



<div class="responsive-tabs">
<h2 class="tabtitle">V3</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag">find . -type f -name '*.pgn' -print0 | xargs -0 -n1 -P8 mawk '/Result/ { split($0, a, &quot;-&quot;); res = substr(a[1], length(a[1]), 1); if (res == 1) white++; if (res == 0) black++; if (res == 2) draw++ } END { print white+black+draw, white, black, draw }' | awk '{games += $1; white += $2; black += $3; draw += $4; } END { print games, white, black, draw }'</pre>
</div></div>



<figure class="wp-block-image size-large"><img width="960" height="540" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-1.png" alt="" class="wp-image-6724" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-1.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-1-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-1-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<figure class="wp-block-image size-large"><img width="960" height="540" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-2.png" alt="" class="wp-image-6723" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-2.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-2-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-2-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<figure class="wp-block-image size-large"><img width="960" height="540" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-3.png" alt="" class="wp-image-6722" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-3.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-3-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-3-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<figure class="wp-block-image size-large"><img width="960" height="540" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-4.png" alt="" class="wp-image-6721" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-4.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-4-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-4-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<figure class="wp-block-image size-large"><img width="960" height="540" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-5.png" alt="" class="wp-image-6720" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-5.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-5-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-5-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<figure class="wp-block-image size-large"><img width="960" height="540" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-6.png" alt="" class="wp-image-6719" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-6.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-6-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-6-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<figure class="wp-block-image size-large"><img width="960" height="540" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-7.png" alt="" class="wp-image-6718" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-7.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-7-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-7-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<figure class="wp-block-image size-large"><img width="960" height="540" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-8.png" alt="" class="wp-image-6717" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-8.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-8-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-8-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<figure class="wp-block-image size-large"><img width="960" height="540" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-9.png" alt="" class="wp-image-6716" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-9.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-9-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd3-9-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<figure class="wp-block-image size-large"><img width="960" height="540" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd-3-11.png" alt="" class="wp-image-6715" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd-3-11.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd-3-11-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd-3-11-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<figure class="wp-block-image size-large"><img width="960" height="540" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd-3-12.png" alt="" class="wp-image-6714" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd-3-12.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd-3-12-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/05/cmd-3-12-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<p></p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/linux/linux-cmd-event-processing-ep3/">玩转Linux命令行 &#8211; 事件处理 &#8211; EP3</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/linux/linux-cmd-event-processing-ep3/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
