Skip to content

Commit 336105f

Browse files
committed
Runtime: 76 ms (Top 5.69%) | Memory: 17.30 MB (Top 7.83%)
1 parent acaab46 commit 336105f

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed
Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
class Solution(object):
2-
def countStudents(self, students, sandwiches):
3-
"""
4-
:type students: List[int]
5-
:type sandwiches: List[int]
6-
:rtype: int
7-
"""
8-
while sandwiches:
9-
if sandwiches[0] in students:
10-
students.remove(sandwiches[0])
1+
// Runtime: 76 ms (Top 5.69%) | Memory: 17.30 MB (Top 7.83%)
2+
3+
class Solution:
4+
def countStudents(self, students: List[int], sandwiches: List[int]) -> int:
5+
count = 0
6+
while len(students) > count:
7+
if students[0] == sandwiches[0]:
118
sandwiches.pop(0)
9+
count = 0
1210
else:
13-
break
14-
return len(sandwiches)
15-
11+
students.append(students[0])
12+
count+=1
13+
14+
students.pop(0)
15+
return len(students)
16+
17+
#Upvote will be encouraging.

0 commit comments

Comments
 (0)