Skip to content

Latest commit

 

History

History
36 lines (29 loc) · 858 Bytes

1700.-number-of-students-unable-to-eat-lunch.md

File metadata and controls

36 lines (29 loc) · 858 Bytes

1700. Number of Students Unable to Eat Lunch

{% 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 %}