Very EASY Solution 🔥🔥🔥|| Beat 100% users🔥✅✅🔥
Intuition\nThe given code appears to be a Java solution to a problem where you have a group of students standing in a queue and a stack of sandwiches with diffe
# Intuition\nThe given code appears to be a Java solution to a problem where you have a group of students standing in a queue and a stack of sandwiches with different types. The task is to count how many students will not be able to get a sandwich\n\n# Approach\nInitialize two variables, stusqusandwich and studcircsandwich, to count the number of students preferring square sandwiches and circular sandwiches, respectively.\nIterate through the students array to count the number of students preferring each type of sandwich.\nIterate through the sandwiches array.\nFor each sandwich, check if it matches the preference of any remaining students.\nIf there are students left with a preference for the current type of sandwich, decrement the count of that type of sandwich preference.\nIf there are no students left with a preference for the current type of sandwich, return the sum of remaining students (as they won\'t be able to get a sandwich).\nIf all sandwiches are distributed, return 0 (indicating all students got their sandwiches).\n\n# Complexity\n- Time complexity:\n $$O(n)$$ \n\n- Space complexity:\n $$O(1)$$ \n\n# Code\n```\nclass Solution {\n    public int countStudents(int[] students, int[] sandwiches) {\n\n        int stusqusandwich=0,studcircsandwich=0;\n        for(int student:students)\n        {\n            if(student==1)\n            {\n                stusqusandwich++;\n            }\n            else\n            {\n                studcircsandwich++;\n            }\n        }\n        for(int sandwich:sandwiches)\n        {\n            if(sandwich==1 && stusqusandwich>0 )\n            {\n                 stusqusandwich--;\n            }\n            else if(sandwich==0 && studcircsandwich>0 )\n            {\n                studcircsandwich--;\n            }\n            else\n            {\n                 return stusqusandwich + studcircsandwich;\n            }\n\n        }\n        return 0;\n        \n    }\n}\n```
['Java']