My 1-line Python

  • 0
    from itertools import izip_longest
    class Solution(object):
        def validWordSquare(self, words):
            :type words: List[str]
            :rtype: bool
            return words==map(''.join,izip_longest(*words,fillvalue=''))

    If we treat the list of lists as a two-dimension matrix where the blank value is filled with ''. The basic idea of this problem is to check whether the matrix is identical to its transpose.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.