Python Swapping Index

  • 7

    alt text

    class Solution(object):
        def validWordSquare(self, words):
            for i in range(len(words)):
                for j in range(len(words[i])):
                    if j >= len(words) or i >= len(words[j]) or words[i][j] != words[j][i]:
                        return False
            return True

Log in to reply

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