mirror of
https://github.com/lWolvesl/leetcode.git
synced 2026-06-04 02:21:15 +08:00
29 lines
371 B
Go
29 lines
371 B
Go
package A
|
|
|
|
func numSpecial(mat [][]int) int {
|
|
res := 0
|
|
x := make(map[int]int)
|
|
y := make(map[int]int)
|
|
for i, row := range mat {
|
|
for j, v := range row {
|
|
if v == 0 {
|
|
continue
|
|
}
|
|
x[i]++
|
|
y[j]++
|
|
}
|
|
}
|
|
for i, row := range mat {
|
|
for j, v := range row {
|
|
if v == 0 {
|
|
continue
|
|
}
|
|
if x[i] == 1 && y[j] == 1 {
|
|
res++
|
|
}
|
|
|
|
}
|
|
}
|
|
return res
|
|
}
|