subject : The original title is link ( Simple )
label : Array
solution
Time complexity
Spatial complexity
Execution time
Ans 1 (Python)
O ( N 2 )
O ( 1 )
100ms (18.99%)
Ans 2 (Python)
Ans 3 (Python)
Solution 1 :
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