# Monotonic Stack Next Greater (Practice 5033): Walkthrough Interviewers use this pattern to test whether you can state the invariant before coding. Here is a compact rehearsal note. ## Approach decreasing stack of idx. ```python def next_greater(a): res=[-1]*len(a); st=[] for i,x in enumerate(a): while st and a[st[-1]]