当前位置:网站首页>LeetCode 1662. Check whether two string arrays are equal
LeetCode 1662. Check whether two string arrays are equal
2022-06-24 04:51:00 【freesan44】
subject
Here are two string arrays word1 and word2 . If two arrays represent the same string , return true ; otherwise , return false .
Array representation string Is made up of all the elements in the array According to the order The string formed by the connection .
Example 1: Input :word1 = ["ab", "c"], word2 = ["a", "bc"] Output :true explain : word1 The string represented is "ab" + "c" -> "abc" word2 The string represented is "a" + "bc" -> "abc" The two strings are the same , return true Example 2: Input :word1 = ["a", "cb"], word2 = ["ab", "c"] Output :false Example 3: Input :word1 = ["abc", "d", "defg"], word2 = ["abcddefg"] Output :true
Tips :
1 <= word1.length, word2.length <= 103
1 <= word1i.length, word2i.length <= 103
1 <= sum(word1i.length), sum(word2i.length) <= 103
word1i and word2i It's made up of lowercase letters
Their thinking
class Solution:
def arrayStringsAreEqual(self, word1: List[str], word2: List[str]) -> bool:
# use join, hold list Turn into str
word1Str = "".join(word1)
word2Str = "".join(word2)
return word1Str == word2Str
if __name__ == '__main__':
word1 = ["ab", "c"]
word2 = ["a", "bc"]
word1 = ["a", "cb"]
word2 = ["ab", "c"]
ret = Solution().arrayStringsAreEqual(word1, word2)
print(ret)边栏推荐
- How to file ECS? What should be paid attention to when selecting ECS
- getAttribute 返回值为null
- 梯度下降法介绍-黑马程序员机器学习讲义
- Integration of Alibaba cloud SMS services and reasons for illegal message signing
- Getattribute return value is null
- Pgbouncer lightweight PG connection pool management tool
- Ext4 file system jam caused by MEM CGroup OOM
- Idea creates a servlet and accesses the 404 message
- What are the functions of ASP files on ECs? What if the ECS cannot run ASP with a low version?
- Summary of Android interview questions in 2020 (intermediate)
猜你喜欢

什么是数据中台

The official overclocking tool of Intel XTU supports win11 22h2 and 13th generation core Raptor Lake processors

Facebook internal announcement: instant messaging will be re integrated
Advanced authentication of uni app [Day12]

梯度下降法介绍-黑马程序员机器学习讲义

SAP mts/ato/mto/eto topic 8: ATO mode 2 d+ empty mode strategy 85

External network access SVN server (external network access SVN server deployed on the cloud)

少儿编程课程改革后的培养方式

Introduction à la méthode de descente par Gradient - document d'apprentissage automatique pour les programmeurs de chevaux noirs

Idea creates a servlet and accesses the 404 message
随机推荐
Bi-sql where
Idea creates a servlet and accesses the 404 message
Huawei cloud gaussdb (for redis) unveiling issue 19: gaussdb (for redis) comprehensive comparison with CODIS
Powerbi - for you who are learning
What are the advantages of ECS? Is ECS better than VM?
C语言自定义类型的介绍(结构体,枚举,联合体,位段)
Advantages of fixed assets management system
How does ECS publish websites? What software tools are needed?
TCPIP协议详解
How to add a domain name to ECS? What are the advantages of ECS?
After purchasing Tencent ECs, how to solve packet loss in Internet access?
Worthington胰蛋白酶的物化性质及特异性
Let children learn the application essence of steam Education
SAP MTS/ATO/MTO/ETO专题之十:ETO模式 Q+空模式 未估价库存 策略自定义
How does ECS build websites? Is it troublesome for ECs to build websites?
Web penetration test - 5. Brute force cracking vulnerability - (9) MS-SQL password cracking
Introduction à la méthode de descente par Gradient - document d'apprentissage automatique pour les programmeurs de chevaux noirs
Abnova fluorescence in situ hybridization (FISH) probe solution
Facebook internal announcement: instant messaging will be re integrated
Web penetration test - 5. Brute force cracking vulnerability - (8) PostgreSQL password cracking