https://leetcode.com/problems/number-of-students-unable-to-eat-lunch/description/ Easy

Решение

class Solution {
    fun countStudents(students: IntArray, sandwiches: IntArray): Int {
        val cnt = IntArray(2)
        for (s in students) cnt[s]++
        for (sand in sandwiches) {
            if (cnt[sand] > 0) cnt[sand]-- else break
        }
        return cnt[0] + cnt[1]
    }
}