✅Easy✨||C++|| Beats 100% || With Explanation ||
\n# Approach\n Describe your approach to solving the problem. \n1. It does not matter how many times we are moving our student from front of queue to back, beca
\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. It does not matter how many times we are moving our student from front of queue to back, because he is only going to take one sandwich, so whenever it takes, does not affect out solution.\n2. If at any time we encountered a sandwich, such that no one in our list of students wants to take that, so in that case we are not able to move ahead and removing that sandwich, so In Simple words the answer would be the count of all sandwiches starting from this position to end of stack.\n3. To Implement this we just have to have count of round and square sandwiches, which students like and we are going to decrement the count, whenever we met that kind of sandwich in stack, So at any point of time, we encounter a sandwich in stack, but count of students want it is equal to 0, that means we can not move ahead, so just simply return the count of rest of sanwiches in stack as our ans.\n\n\n# Code\n```\n\nclass Solution {\npublic:\n    int countStudents(vector<int>& students, vector<int>& sandwiches) {\n        int ones = 0, zeroes = 0;\n        for(int i : students) {\n            \n            ones += i;\n        }\n        zeroes = students.size() - ones;\n        \n        for(int i = 0; i < sandwiches.size(); i++) {\n            \n            int val = sandwiches[i];\n            if(val == 0) {\n                \n                if(zeroes == 0) {\n                    \n                    return sandwiches.size() - i;\n                }\n                zeroes--;\n            } else {\n                \n                if(ones == 0) {\n                    \n                    return sandwiches.size() - i;\n                }\n                ones--;\n            }\n        }\n        \n        return 0;\n    }\n};\n   \n```
['C++']