Skip to content

Latest commit

 

History

History

number-of-students-unable-to-eat-lunch

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Number of students unable to eat lunch

Problem link

Solutions

Solution.py

# https://leetcode.com/problems/number-of-students-unable-to-eat-lunch/

class Solution:
    def countStudents(self, students: List[int], sandwiches: List[int]) -> int:
        cnt = Counter(students)
        ret = len(sandwiches)
        for x in sandwiches:
            if cnt[x]:
                cnt[x] -= 1
                ret -= 1
            else:
                break
        return ret

Tags