LeetCode题解(0422):有效的单词方块(Python)

大雁f

关注

阅读 37

2022-02-24


题目:​​原题链接​​(简单)

标签:数组

解法

时间复杂度

空间复杂度

执行用时

Ans 1 (Python)

O ( N 2 )

O ( 1 )

100ms (18.99%)

Ans 2 (Python)

Ans 3 (Python)

解法一:

class Solution:
def validWordSquare(self, words: List[str]) -> bool:
for i in range(len(words)):
for j in range(len(words[i])):
if len(words) <= j or len(words[j]) <= i or words[i][j] != words[j][i]:
return False
return True



精彩评论(0)

0 0 举报