1944. Number of Visible People in a Queue
Содержание
class Solution:
def canSeePersonsCount(self, heights: List[int]) -> List[int]:
n = len(heights)
res = [0] * n
stk = []
for i in range(n - 1, -1, -1):
while stk and stk[-1] < heights[i]:
res[i] += 1
stk.pop()
if stk:
res[i] += 1
stk.append(heights[i])
return res