Python代码:
def nextGreaterElement(self, findNums, nums):
"""
:type findNums: List[int]
:type nums: List[int]
:rtype: List[int]
"""
st = []
dic = {}
for num in nums:
while len(st) and st[-1]<num:
dic[st.pop()] = num
st.append(num)
return [dic.get(x,-1) for x in findNums]