只需一次遍历: class Solution: def foundMonotoneStack(self , nums: List[int]) -> List[List[int]]: stack = [] ans = [[-1, -1] for _ in range(len(nums))] for i in range(len(nums)): while stack and nums[stack[-1]] > nums[i]: ans[stack[-1]][1] = i ...