888. Effective word square word
Chinese
English
Given a sequence of words, check whether it constitutes a valid word square.
Place a valid word should satisfy the following conditions: For satisfying 0≤k<max(numRows numColumns)
the k
first k
row and first k
column corresponding to the character string should be the same.
Sample
Sample 1
输入:
[
"abcd",
"bnrt",
"crmy",
"dtye"
]
输出: true
解释:
第一行和第一列都是“abcd”。
第二行和第二列都是“bnrt”。
第三行和第三列都是“crmy”。
第四行和第四列都是“dtye”。
因此,这是一个有效的单词广场.
Sample 2
输入:
[
"abcd",
"bnrt",
"crm",
"dt"
]
输出: true
解释:
第一行和第一列都是“abcd”。
第二行和第二列都是“bnrt”。
第三行和第三列都是“crm”。
第四行和第四列都是“dt”。
因此,这是一个有效的单词广场.
Sample 3
输入:
[
"ball",
"area",
"read",
"lady"
]
输出: false
解释:
第三行是 "read" 但是第三列是 "lead".
因此,这不是一个有效的单词广场.
Precautions
Given the number of words is at least 1 and not more than 500
.
Word length is at least 1 and not more than 500
.
Each word contains only lowercase letters a-z
.