Go/C O(n) 0ms, 2.2MB/5.9MB (100%/100%), Swift 8 ms
Go:\n\nfunc countStudents(students []int, sandwiches []int) int {\n    var counters [2]int\n\t// count zeros and ones in students\n    for i := 0; i < len(stude
Go:\n```\nfunc countStudents(students []int, sandwiches []int) int {\n    var counters [2]int\n\t// count zeros and ones in students\n    for i := 0; i < len(students); i++ {\n        counters[students[i]]++\n    }\n\t// go over the sandwiches queue\n    for i := 0; i < len(sandwiches); i++ {\n        if counters[sandwiches[i]] == 0 {\n            break  // stop if there is no student of the kind left\n        }\n        counters[sandwiches[i]]--  // decrement number of students of the kind\n    }\n    // return number of students left\n\treturn counters[0] + counters[1]\n}\n```\nC:\n```\nint countStudents(int* students, int studentsSize, int* sandwiches, int sandwichesSize){\n    int i, ctr[2] = {0, 0};\n    // count zeros and ones in students\n    for (i = 0; i < studentsSize; i++)\n        ctr[students[i]]++;\n    // go over the sandwiches queue\n    for (i = 0; i < sandwichesSize; i++) {\n        if (ctr[sandwiches[i]] == 0)\n            break;  // stop if there is no student of the kind left\n        ctr[sandwiches[i]]--;  // decrement number of students of the kind\n    }\n    // return number of students left\n\treturn ctr[0] + ctr[1];\n}\n```\nSwift:\n```\nclass Solution {\n    func countStudents(_ students: [Int], _ sandwiches: [Int]) -> Int {\n        var ctrs: [Int] = [0, 0]\n        // count zeros and ones in students\n        ctrs[1] = students.reduce(0, +)\n        ctrs[0] = students.count - ctrs[1]\n        // go over the sandwiches queue\n        for s in sandwiches {\n            if ctrs[s] == 0 {\n                break  // stop if there is no student of the kind left\n            }\n            ctrs[s] -= 1  // decrement number of students of the kind\n        }\n        // return number of students left\n        return Int(max(ctrs[0], ctrs[1]))\n    }\n}\n```
['Swift', 'C', 'Go']