mirror of
https://github.com/lWolvesl/leetcode.git
synced 2026-06-04 02:21:15 +08:00
routine
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user