Golang | Leetcode Golang题解之第36题有效的数独

题目:

题解:

Go 复制代码
func isValidSudoku(board [][]byte) bool {
    var rows, columns [9][9]int
    var subboxes [3][3][9]int
    for i, row := range board {
        for j, c := range row {
            if c == '.' {
                continue
            }
            index := c - '1'
            rows[i][index]++
            columns[j][index]++
            subboxes[i/3][j/3][index]++
            if rows[i][index] > 1 || columns[j][index] > 1 || subboxes[i/3][j/3][index] > 1 {
                return false
            }
        }
    }
    return true
}
相关推荐
shehuiyuelaiyuehao12 小时前
算法21,搜索插入位置
python·算法·leetcode
_深海凉_13 小时前
LeetCode热题100-回文链表
算法·leetcode·链表
小雅痞13 小时前
[Java][Leetcode middle] 54. 螺旋矩阵
java·leetcode·矩阵
pursuit_csdn13 小时前
力扣周赛 501
算法·leetcode·职场和发展
AbandonForce13 小时前
LeetCode 滑动窗口个人思路详解
算法·leetcode·职场和发展
金玉满堂@bj13 小时前
Go 语言能做什么?
开发语言·后端·golang
Liangwei Lin13 小时前
LeetCode 45. 跳跃游戏 II
数据结构·算法·leetcode
geovindu13 小时前
go:Condition Variable Pattern
开发语言·后端·设计模式·golang·条件变量模式
金玉满堂@bj13 小时前
Gin 框架零基础全套入门教程(Go 企业级 Web 开发)
前端·golang·gin
OYangxf14 小时前
力扣hot100【子串专题】
算法·leetcode·职场和发展