|
| 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> </p> |
| 6 | +<p><strong class="example">Example 1:</strong></p> |
| 7 | + |
| 8 | +<pre> |
| 9 | +<strong>Input:</strong> word1 = ["ab", "c"], word2 = ["a", "bc"] |
| 10 | +<strong>Output:</strong> true |
| 11 | +<strong>Explanation:</strong> |
| 12 | +word1 represents string "ab" + "c" -> "abc" |
| 13 | +word2 represents string "a" + "bc" -> "abc" |
| 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 = ["a", "cb"], word2 = ["ab", "c"] |
| 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 = ["abc", "d", "defg"], word2 = ["abcddefg"] |
| 27 | +<strong>Output:</strong> true |
| 28 | +</pre> |
| 29 | + |
| 30 | +<p> </p> |
| 31 | +<p><strong>Constraints:</strong></p> |
| 32 | + |
| 33 | +<ul> |
| 34 | + <li><code>1 <= word1.length, word2.length <= 10<sup>3</sup></code></li> |
| 35 | + <li><code>1 <= word1[i].length, word2[i].length <= 10<sup>3</sup></code></li> |
| 36 | + <li><code>1 <= sum(word1[i].length), sum(word2[i].length) <= 10<sup>3</sup></code></li> |
| 37 | + <li><code>word1[i]</code> and <code>word2[i]</code> consist of lowercase letters.</li> |
| 38 | +</ul> |
0 commit comments