66ms, 7 lines, beating 95% - Python Code


  • 2
    R
    class Solution(object):
        def validWordSquare(self, words):
            """
            :type words: List[str]
            :rtype: bool
            """
            length = len( words )
            for k, v in enumerate(words):
                 if len( v ) > length:
                    return False
                 if len( v ) < length:
                    words[ k ] += ' '* ( length - len( v ) )
                                                
            return words == list(map(''.join,zip(*words)))
    

Log in to reply
 

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