给你俩个字符数组word1和word2。如果俩个数组表示的字符串相同,返回true;否则,返回false。数组表示的字符串是有数组中的所有元素按顺序连接形成的字符串。
示例 1:
输入:word1 = ["ab", "c"], word2 = ["a", "bc"] 输出:true 解释: word1 表示的字符串为 "ab" + "c" -> "abc" word2 表示的字符串为 "a" + "bc" -> "abc" 两个字符串相同,返回 true
示例 2:
输入:word1 = ["a", "cb"], word2 = ["ab", "c"] 输出:false
示例 3:
输入:word1 = ["abc", "d", "defg"], word2 = ["abcddefg"] 输出:true
class Solution:
def arrayStringsAreEqual(self, word1: List[str], word2: List[str]) -> bool:
return ''.join(word1) == ''.join(word2)