Narrowest Road Section
A service lane is split into sections, and each section shows the widest vehicle that can pass through it. The function service_lane receives a list width and a list of queries cases, where each query gives a section range from i to j, inclusive. For each range, find the narrowest section, because it determines which vehicle can pass through the whole segment. Return the answers for all queries as a list.
Примеры
Ввод
[2, 3, 1, 2, 3, 2, 3, 3], [[0, 3], [4, 6], [6, 7], [3, 5], [0, 7]]Вывод
[1, 2, 3, 2, 1]Ввод
[1, 2, 2, 2, 1], [[2, 3]]Вывод
[2]Ввод
[3, 3, 3], [[0, 2]]Вывод
[3]Нужно реализовать
def service_lane(width: list[int], cases: list[list[int]]) -> list[int]:
Теги
arraymath
Pieslēdzies, lai redzētu iesniegumu vēsturi
PieslēgtiesPieslēdzies, lai izmantotu AI mentoru
PieslēgtiesVisible tests
1
Input
[2,3,1,2,3,2,3,3], [[0,3],[4,6],[6,7],[3,5],[0,7]]Expected
[1,2,3,2,1]2
Input
[1,2,2,2,1], [[2,3]]Expected
[2]3
Input
[3,3,3], [[0,2]]Expected
[3]4
Input
[1,1,1], [[0,0],[1,2]]Expected
[1,1]5
Input
[2,3,2], [[0,1],[1,2]]Expected
[2,2]6
Input
[2,3,1,2,3,2,3,3], []Expected
[]Focus radio
Paused · SomaFM · Fluid