java.lang.Object
g1601_1700.s1662_check_if_two_string_arrays_are_equivalent.Solution

public class Solution extends Object
1662 - Check If Two String Arrays are Equivalent.<p>Easy</p> <p>Given two string arrays <code>word1</code> and <code>word2</code>, return <code>true</code> <em>if the two arrays <strong>represent</strong> the same string, and</em> <code>false</code> <em>otherwise.</em></p> <p>A string is <strong>represented</strong> by an array if the array elements concatenated <strong>in order</strong> forms the string.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> word1 = [&ldquo;ab&rdquo;, &ldquo;c&rdquo;], word2 = [&ldquo;a&rdquo;, &ldquo;bc&rdquo;]</p> <p><strong>Output:</strong> true</p> <p><strong>Explanation:</strong></p> <p>word1 represents string &ldquo;ab&rdquo; + &ldquo;c&rdquo; -> &ldquo;abc&rdquo;</p> <p>word2 represents string &ldquo;a&rdquo; + &ldquo;bc&rdquo; -> &ldquo;abc&rdquo;</p> <p>The strings are the same, so return true.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> word1 = [&ldquo;a&rdquo;, &ldquo;cb&rdquo;], word2 = [&ldquo;ab&rdquo;, &ldquo;c&rdquo;]</p> <p><strong>Output:</strong> false</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> word1 = [&ldquo;abc&rdquo;, &ldquo;d&rdquo;, &ldquo;defg&rdquo;], word2 = [&ldquo;abcddefg&rdquo;]</p> <p><strong>Output:</strong> true</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= word1.length, word2.length <= 10<sup>3</sup></code></li> <li><code>1 <= word1[i].length, word2[i].length <= 10<sup>3</sup></code></li> <li><code>1 <= sum(word1[i].length), sum(word2[i].length) <= 10<sup>3</sup></code></li> <li><code>word1[i]</code> and <code>word2[i]</code> consist of lowercase letters.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • arrayStringsAreEqual

      public boolean arrayStringsAreEqual(String[] word1, String[] word2)