People Left on the Bus
Imagine a bus route where people get on and off at every stop. Write number, which takes a list stops, where each stop is written as [in, out]. The bus starts empty, and you need to return how many people are still on the bus after the final stop.
Примеры
Ввод
[[10, 0], [3, 5], [5, 8]]Вывод
5Ввод
[[3, 0], [9, 1], [4, 10], [12, 2], [6, 1], [7, 10]]Вывод
17Ввод
[[0, 0]]Вывод
0Нужно реализовать
def number(stops: list[list[int]]) -> int:
Теги
arraymath
Entre para ver seu histórico de envios
EntrarEntre para usar o AI Mentor
EntrarVisible tests
1
Input
[[10,0],[3,5],[5,8]]Expected
52
Input
[[3,0],[9,1],[4,10],[12,2],[6,1],[7,10]]Expected
173
Input
[[0,0]]Expected
04
Input
[[5,0],[0,5]]Expected
05
Input
[[2,0],[2,1]]Expected
36
Input
[[10,0],[3,5],[5,8],[10,0]]Expected
15Focus radio
Paused · SomaFM · Fluid