728x90
https://leetcode.com/problems/number-of-students-unable-to-eat-lunch
class Solution:
def countStudents(self, students: List[int], sandwiches: List[int]) -> int:
count = 0
while students:
if students[0] == sandwiches[0]:
students.pop(0)
sandwiches.pop(0)
count = 0
else:
students.append(students.pop(0))
count += 1
if count == len(students):
return count
return 0
728x90
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 3110. Score of a String (0) | 2024.04.13 |
---|---|
[Leetcode] 2073. Time Needed to Buy Tickets (0) | 2024.04.09 |
[Leetcode] 678. Valid Parenthesis String (0) | 2024.04.07 |
[Leetcode] 1544. Make The String Great (0) | 2024.04.05 |
[Leetcode] 938. Range Sum of BST (0) | 2024.04.05 |