https://leetcode.com/problems/cells-with-odd-values-in-a-matrix/description/ Easy

Решение

class Solution {
    fun oddCells(m: Int, n: Int, indices: Array<IntArray>): Int {
        val rows = IntArray(m)
        val cols = IntArray(n)

        for ((r, c) in indices) {
            rows[r]++
            cols[c]++
        }

        var count = 0
        for (i in 0 until m) {
            for (j in 0 until n) {
                if ((rows[i] + cols[j]) % 2 != 0) {
                    count++
                }
            }
        }

        return count
    }
}