【Leetcode】422. Valid Word Square

Given a sequence of words, check whether it forms a valid word square.

A sequence of words forms a valid word square if the kth row and column read the exact same string, where 0 ≤ k < max(numRows, numColumns).

class Solution(object):

    def validWordSquare(self, words):

        """

        :type words: List[str]

        :rtype: bool

        """

        t = map(None, *words)

        return t == map(None, *t)

1 得到输入matrix的transpose,并在没有str的地方填None

2 判断transpose后是否相等

你可能感兴趣的:(【Leetcode】422. Valid Word Square)