Simple python solution using queues
Intuition\n Describe your first thoughts on how to solve this problem. \nThe Intuition is simple we\'ll use a queue inorder to solve the problem . As per the gi
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe Intuition is simple we\'ll use a queue inorder to solve the problem . As per the given rules we are going to pop out of sandwiches and students if they match and if they don\'t we\'ll send the 1st member to the last position .\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe\'ll check whether the first sandwich is present or not in the student queue if it is not present then we\'ll return the length of remaining students , if the length of sandwiches is zero i.e. all the students are able to eat we return an empty students list . So these are the conditions for the while loop . In the while loop if 1st sandwich matches the 1st student we pop the 1st student and 1st sandwich . Else we append it to the end of the student queue.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nIn the worst case we need to pop out all the sandwiches . Therefore the time complexity is $$O(n)$$\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nWe haven\'t used any extra space so the space complexity is $$O(1)$$\n\n# Code\n```\nclass Solution:\n    def countStudents(self, students: List[int], sandwiches: List[int]) -> int:\n        while len(sandwiches)!=0 and sandwiches[0] in students:\n            if students[0]==sandwiches[0]:\n                students.pop(0)\n                sandwiches.pop(0)\n            else:\n                students.append(students.pop(0))\n        return len(students)\n\n        \n```
['Python3']