1662. Check If Two String Arrays are Equivalent
给你两个字串阵列
回传两个阵列是否表示相同字串
把阵列元素按顺序连接在一起之后就是他的字串
Input: word1 = ["ab", "c"], word2 = ["a", "bc"]
Output: true
word1: "ab" + "c" -> "abc"
word2: "a" + "bc" -> "abc"
Input: word1 = ["a", "cb"], word2 = ["ab", "c"]
Output: false
Input: word1 = ["abc", "d", "defg"], word2 = ["abcddefg"]
Output: true
Approach:
用join合并之后直接比较
TS Code:
function arrayStringsAreEqual (word1: string[], word2: string[]): boolean {
return word1.join('') === word2.join('')
}