Day 34
Date: November 1, 2022 8:51 AM
LinkedIn: https://leetcode.cn/problems/check-if-two-string-arrays-are-equivalent/description/
Title: 检查两个字符串数组是否相等
class Solution:
def arrayStringsAreEqual(self, word1: List[str], word2: List[str]) -> bool:
str1 = ''.join(word1)
str2 = ''.join(word2)
return str1 == str2
拼接列表字符串
-
字符串=‘分隔符’.join(列表)
- 如:
words=['a','b','c'] str1=' '.join(words) print(str1) # a b c
words=['a','b','c'] str1=''.join(words) print(str1) # abc