Check If Two String Arrays are Equivalent

Easy

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:true
Explanation:

Both form abc.

Input:word1 = ["hello", "world"], word2 = ["hellow", "orld"]
Output:true
Explanation:

word1 concatenates to "helloworld" and word2 concatenates to "helloworld". Both arrays represent the same string.

Input:word1 = ["cat", "dog"], word2 = ["cat", "fish"]
Output:false
Explanation:

word1 concatenates to "catdog" while word2 concatenates to "catfish". The two arrays represent different strings.

Constraints

  • 1 ≤ word1.length, word2.length ≤ 10^3

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!