LeetCode 1662 Check If Two String Arrays are Equivalent (Python)

Posted by 小明MaxMing on January 8, 2020

题目

Given two string arrays word1 and word2, return true if the two arrays represent the same string, and false otherwise.

A string is represented by an array if the array elements concatenated in order forms the string.

解题思路

将两个数组join到一起进行比较

代码

class Solution:
    def arrayStringsAreEqual(self, word1: List[str], word2: List[str]) -> bool:
        return ''.join(word1) == ''.join(word2)

视频讲解 YouTube<--欢迎点击订阅

视频讲解 bilibili<--欢迎点击订阅