Very Easy Beginner Friendly || Simple Counting || Beats 100% ✅✅
Intuition\nEating the sandwich until which can be eaten and then returning the number of sandwiches which cannot be eaten.\n\n# Approach\nCount the number of st
# Intuition\nEating the sandwich until which can be eaten and then returning the number of sandwiches which cannot be eaten.\n\n# Approach\nCount the number of students prefering ones and zeroes in two variables. Then from the start of the sandwich array match the student demand and the sandwich on top if it is required. If it is not, then return the number of sandwiches left that is total-current index.\n\n# Complexity\n- Time complexity:\n$$O(n)$$ \n\n- Space complexity:\n$$O(1)$$ \n\n# Code\n```\nclass Solution {\npublic:\n    int countStudents(vector<int>& students, vector<int>& sandwiches) {\n        \n        int zero = 0, one = 0;\n        for(int i=0; i<students.size(); i++){\n            if(students[i]==0){\n                zero++;\n            }\n            else{\n                one++;\n            }\n        }\n        for(int i=0; i<sandwiches.size(); i++){\n            if(sandwiches[i]==1 && one>0){\n                one--;\n                continue;\n            }\n            else if(sandwiches[i]==0 && zero>0){\n                zero--;\n                continue;\n            }\n            else{\n                return sandwiches.size()-i;\n            }\n        }\n        return 0;\n\n    }\n};\n```
['Array', 'Stack', 'Queue', 'Simulation', 'C++']