Golang 6ms, checks each corresponding point


  • 0
    R
    func validWordSquare(words []string) bool {
        for i:= 0; i < len(words); i++ {
            for j:=0; j < len(words[i]); j++ {
                if j>= len(words) || len(words[j]) <= i || words[j][i] != words[i][j] {
                    return false
                }
                    
            }
        }
        return true
    }
    

Log in to reply
 

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