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
}
相关推荐
平头哥AI1 小时前
Day 22 _ 包装错误别丢链_%w、errors.Is 与 errors.As
android·服务器·学习·golang·go
Navigator_Z5 小时前
LeetCode //C - 1240. Tiling a Rectangle with the Fewest Squares
c语言·算法·leetcode
稻米哟5 小时前
力扣100——双指针
算法·leetcode
golang学习记6 小时前
Go 1.27新特性: json/v2使用有趣指南
开发语言·golang·json
王码码20357 小时前
Go语言CGO:Go与C交互
后端·golang·go·接口
PC2005-cloud8 小时前
DSH 白嫖指南:接入 Command Code Go、WorkBuddy 与 Trae 的免费额度
开发语言·后端·golang
橘子汽水1689 小时前
Leetcode 198,118打家劫舍,杨辉三角
算法·leetcode
名字还没想好☜9 小时前
Docker 镜像瘦身进阶:用 distroless/scratch 把 Go 服务打到 10MB,以及没 shell 怎么调试
运维·docker·容器·golang·kubernetes
lvshuocool9 小时前
golang 多版本管理工具 -- g
开发语言·后端·golang
海盗123412 小时前
DSH 接入 OpenCode Go 报 400 MissingSessionID:从 LLM 语义层退到 fetch 传输层的完整排障
开发语言·后端·golang