题解 | 无法吃午餐的学生数量python
无法吃午餐的学生数量
https://www.nowcoder.com/practice/2dac3d7567f741a88ec551caf907934d
#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param students int整型一维数组
# @param sandwiches int整型一维数组
# @return int整型
#
class Solution:
def countStudents(self , students: List[int], sandwiches: List[int]) -> int:
# write code here
num = 0
while len(students) != 0:
if students[0] == sandwiches[0]:
students.pop(0)
sandwiches.pop(0)
num = 0
else:
students.append(students.pop(0))
num += 1
if num > len(students):
return len(students)
return 0

