IT/코딩테스트
[Leetcode] 1700. Number of Students Unable to Eat Lunch
이주디
2024. 4. 8. 20:45
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