Description
Given two string arrays word1 and word2, return true if the two arrays represent the same string when concatenated.
Examples
Input:
word1 = ["ab", "c"], word2 = ["a", "bc"]Output:
trueExplanation:
Both form abc.
Input:
word1 = ["hello", "world"], word2 = ["hellow", "orld"]Output:
trueExplanation:
word1 concatenates to "helloworld" and word2 concatenates to "helloworld". Both arrays represent the same string.
Input:
word1 = ["cat", "dog"], word2 = ["cat", "fish"]Output:
falseExplanation:
word1 concatenates to "catdog" while word2 concatenates to "catfish". The two arrays represent different strings.
Constraints
- •
1 ≤ word1.length, word2.length ≤ 10^3