-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe1700 v2.py
30 lines (26 loc) · 956 Bytes
/
e1700 v2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class Solution:
def countStudents(self, students: List[int], sandwiches: List[int]) -> int:
squareStudents = sum(students)
currStudent = 0
while True:
if sandwiches[0] :
if not squareStudents :
break
elif students[currStudent] :
students.pop(currStudent)
sandwiches.pop(0)
squareStudents -= 1
else :
currStudent += 1
else :
if not (len(students) - squareStudents) :
break
elif not students[currStudent] :
students.pop(currStudent)
sandwiches.pop(0)
else :
currStudent += 1
if len(students) == 0 :
break
currStudent %= len(students)
return len(students)