Java || Stack || Que || Expalined
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int countStudents(int[] students, int[] sandwiches) {\n          Stack<Integer> stack=new Stack<>();\n        Deque<Integer> dq=new LinkedList<>();\n        // -Pushing Sandwiches in Stack\n        for (int i = sandwiches.length-1; i>=0; i--) {\n           stack.push(sandwiches[i]);\n        }\n        // - Created Deque to add from both side\n        for (int i = 0; i < students.length; i++) {\n            dq.add(students[i]);\n        }\n        int eaten=0;\n// To make sure that we dont get stuck in infinte Loop\n        int count= 0;\n        while (!stack.isEmpty()){\n// If equal then Remove those elements from stack and queue\n            if (Objects.equals(stack.peek(), dq.peek())){\n                count=0;\n                eaten++;\n                stack.pop();\n                dq.poll();\n            }else {\n// Else remove the first element and move it to last\n                count++;\n                int temp = dq.peekFirst();\n                dq.pollFirst();\n                dq.addLast(temp);\n            }\n// If this condition hits that means we have checked for all and no more comparisons are required\n            if (count==dq.size()){\n                break;\n            }\n        }\n        return students.length-eaten;\n    }\n}\n```
['Array', 'Stack', 'Queue', 'Simulation', 'Java']