Check If Two String Arrays are Equivalent

Easy Topics Company Tags

Concatenate the strings in word1 in their given order, and do the same for word2. Return true if the two resulting strings are identical, or false otherwise. The boundaries between the individual pieces do not affect the comparison.

Example 1:

Input: word1 = ["ne","et"]
word2 = ["n","eet"]

Output: true

Explanation: Both arrays form "neet". Their pieces have different boundaries, but the resulting characters match exactly.

Example 2:

Input: word1 = ["ab","cd"]
word2 = ["ab","ce"]

Output: false

Explanation: The first array forms "abcd", while the second forms "abce". Their last characters differ, so return false.

Example 3:

Input: word1 = ["abc"]
word2 = ["ab"]

Output: false

Explanation: The arrays form "abc" and "ab". One has an extra character, so they are not equal.

Constraints:

  • Each array contains between 1 and 1000 strings.
  • Each string contains between 1 and 1000 lowercase English letters.
  • The total number of characters in each array is at most 1000.


Topics

Company Tags

Please upgrade to NeetCode Pro to view company tags.