LeetCode Entry
1582. Special Positions in a Binary Matrix
#### Join me on Telegram
1582. Special Positions in a Binary Matrix easy
blog post
substack

Join me on Telegram
https://t.me/leetcode_daily_unstoppable/437
Complexity
-
Time complexity: \(O((nm)^2)\)
-
Space complexity: \(O(1)\)
Code
fun numSpecial(mat: Array<IntArray>): Int {
var count = 0
for (y in 0..mat.lastIndex)
for (x in 0..mat[y].lastIndex)
if (mat[y][x] == 1
&& (0..mat.lastIndex).filter { it != y }.all { mat[it][x] == 0}
&& (0..mat[y].lastIndex).filter { it != x }.all { mat[y][it] == 0})
count++
return count
}