<?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>concat Archives - Huahua&#039;s Tech Road</title>
	<atom:link href="https://zxi.mytechroad.com/blog/tag/concat/feed/" rel="self" type="application/rss+xml" />
	<link>https://zxi.mytechroad.com/blog/tag/concat/</link>
	<description></description>
	<lastBuildDate>Fri, 31 Dec 2021 22:11:43 +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>concat Archives - Huahua&#039;s Tech Road</title>
	<link>https://zxi.mytechroad.com/blog/tag/concat/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>花花酱 LeetCode 1961. Check If String Is a Prefix of Array</title>
		<link>https://zxi.mytechroad.com/blog/string/leetcode-1961-check-if-string-is-a-prefix-of-array/</link>
					<comments>https://zxi.mytechroad.com/blog/string/leetcode-1961-check-if-string-is-a-prefix-of-array/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Fri, 31 Dec 2021 22:11:02 +0000</pubDate>
				<category><![CDATA[String]]></category>
		<category><![CDATA[concat]]></category>
		<category><![CDATA[easy]]></category>
		<category><![CDATA[string]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=9332</guid>

					<description><![CDATA[<p>Given a string&#160;s&#160;and an array of strings&#160;words, determine whether&#160;s&#160;is a&#160;prefix string&#160;of&#160;words. A string&#160;s&#160;is a&#160;prefix string&#160;of&#160;words&#160;if&#160;s&#160;can be made by concatenating the first&#160;k&#160;strings in&#160;words&#160;for some&#160;positive&#160;k&#160;no larger than&#160;words.length.&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/string/leetcode-1961-check-if-string-is-a-prefix-of-array/">花花酱 LeetCode 1961. Check If String Is a Prefix of Array</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>Given a string&nbsp;<code>s</code>&nbsp;and an array of strings&nbsp;<code>words</code>, determine whether&nbsp;<code>s</code>&nbsp;is a&nbsp;<strong>prefix string</strong>&nbsp;of&nbsp;<code>words</code>.</p>



<p>A string&nbsp;<code>s</code>&nbsp;is a&nbsp;<strong>prefix string</strong>&nbsp;of&nbsp;<code>words</code>&nbsp;if&nbsp;<code>s</code>&nbsp;can be made by concatenating the first&nbsp;<code>k</code>&nbsp;strings in&nbsp;<code>words</code>&nbsp;for some&nbsp;<strong>positive</strong>&nbsp;<code>k</code>&nbsp;no larger than&nbsp;<code>words.length</code>.</p>



<p>Return&nbsp;<code>true</code><em>&nbsp;if&nbsp;</em><code>s</code><em>&nbsp;is a&nbsp;<strong>prefix string</strong>&nbsp;of&nbsp;</em><code>words</code><em>, or&nbsp;</em><code>false</code><em>&nbsp;otherwise</em>.</p>



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



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> s = "iloveleetcode", words = ["i","love","leetcode","apples"]
<strong>Output:</strong> true
<strong>Explanation:</strong>
s can be made by concatenating "i", "love", and "leetcode" together.
</pre>



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



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> s = "iloveleetcode", words = ["apples","i","love","leetcode"]
<strong>Output:</strong> false
<strong>Explanation:</strong>
It is impossible to make s using a prefix of arr.</pre>



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



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



<h2><strong>Solution: Concat and test</strong></h2>



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



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

<pre class="crayon-plain-tag">// Author: Huahua
class Solution {
public:
  bool isPrefixString(string s, vector&lt;string&gt;&amp; words) {
    string t;
    for (const string&amp; w : words) {
      t += w;
      if (t.length() &gt;= s.length()) break;
    }
    return t == s;
  }
};</pre>
</div></div>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/string/leetcode-1961-check-if-string-is-a-prefix-of-array/">花花酱 LeetCode 1961. Check If String Is a Prefix of Array</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-1961-check-if-string-is-a-prefix-of-array/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
