Skip to content

Commit e16522c

Browse files
committed
[LeetCode Sync] Runtime - 0 ms (100.00%), Memory - 12.4 MB (91.67%)
1 parent 67d8072 commit e16522c

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<p>Given two string arrays <code>word1</code> and <code>word2</code>, return<em> </em><code>true</code><em> if the two arrays <strong>represent</strong> the same string, and </em><code>false</code><em> otherwise.</em></p>
2+
3+
<p>A string is <strong>represented</strong> by an array if the array elements concatenated <strong>in order</strong> forms the string.</p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong class="example">Example 1:</strong></p>
7+
8+
<pre>
9+
<strong>Input:</strong> word1 = [&quot;ab&quot;, &quot;c&quot;], word2 = [&quot;a&quot;, &quot;bc&quot;]
10+
<strong>Output:</strong> true
11+
<strong>Explanation:</strong>
12+
word1 represents string &quot;ab&quot; + &quot;c&quot; -&gt; &quot;abc&quot;
13+
word2 represents string &quot;a&quot; + &quot;bc&quot; -&gt; &quot;abc&quot;
14+
The strings are the same, so return true.</pre>
15+
16+
<p><strong class="example">Example 2:</strong></p>
17+
18+
<pre>
19+
<strong>Input:</strong> word1 = [&quot;a&quot;, &quot;cb&quot;], word2 = [&quot;ab&quot;, &quot;c&quot;]
20+
<strong>Output:</strong> false
21+
</pre>
22+
23+
<p><strong class="example">Example 3:</strong></p>
24+
25+
<pre>
26+
<strong>Input:</strong> word1 = [&quot;abc&quot;, &quot;d&quot;, &quot;defg&quot;], word2 = [&quot;abcddefg&quot;]
27+
<strong>Output:</strong> true
28+
</pre>
29+
30+
<p>&nbsp;</p>
31+
<p><strong>Constraints:</strong></p>
32+
33+
<ul>
34+
<li><code>1 &lt;= word1.length, word2.length &lt;= 10<sup>3</sup></code></li>
35+
<li><code>1 &lt;= word1[i].length, word2[i].length &lt;= 10<sup>3</sup></code></li>
36+
<li><code>1 &lt;= sum(word1[i].length), sum(word2[i].length) &lt;= 10<sup>3</sup></code></li>
37+
<li><code>word1[i]</code> and <code>word2[i]</code> consist of lowercase letters.</li>
38+
</ul>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution(object):
2+
def arrayStringsAreEqual(self, word1, word2):
3+
"""
4+
:type word1: List[str]
5+
:type word2: List[str]
6+
:rtype: bool
7+
"""
8+
def add_func(words):
9+
res = ''
10+
for word in words:
11+
res += word
12+
return res
13+
14+
ans1 = add_func(word1)
15+
ans2 = add_func(word2)
16+
return ans1 == ans2
17+

0 commit comments

Comments
 (0)