Skip to main content

Check If Two String Arrays are Equivalent

EasyArrayString

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 and sharpen your skills for technical interviews.