{% tabs %} {% tab title="Python-me" %}
cnt = 0
while students and sandwiches and cnt < len(students):
if students[0] == sandwiches[0]:
sandwiches = sandwiches = sandwiches[1:]
students = students[1:]
cnt = 0
else:
students = students[1:] + [students[0]]
cnt += 1
return len(students)
{% endtab %}
{% tab title="Python" %}
class Solution:
def countStudents(self, A: List[int], B: List[int]) -> int:
count = collections.Counter(A)
n, k = len(A), 0
while k < n and count[B[k]]:
count[B[k]] -= 1
k += 1
return n - k
{% endtab %} {% endtabs %}