Java Easy Solution Using Stack & Queue 👍
\nclass Solution {\n    public int countStudents(int[] students, int[] sandwiches) {\n        Queue<Integer> q = new LinkedList<>();\n        Stack<Integer> s =
```\nclass Solution {\n    public int countStudents(int[] students, int[] sandwiches) {\n        Queue<Integer> q = new LinkedList<>();\n        Stack<Integer> s = new Stack<>();\n        for (int i = sandwiches.length - 1; i >= 0; i--) {\n            s.add(sandwiches[i]);\n        }\n        for (int student : students) {\n            q.add(student);\n        }\n        int count = 0;\n        while (s.size() != 0) {\n            if (Objects.equals(s.peek(), q.peek())) {\n                count = 0;\n                s.pop();\n                q.poll();\n            } else {\n                int top = q.poll();\n                q.add(top);\n                count++;\n            }\n\n            if (count == q.size()) {\n                return count;\n            }\n        }\n\n        return 0;\n    }\n}\n```
['Stack', 'Queue', 'Java']