Next Greater Element I
class Solution:
def nextGreaterElement(self, nums1: List[int], nums2: List[int]) -> List[int]:
stack = []
cache = {}
for n in nums2:
while stack and stack[-1] < n:
k = stack.pop()
cache[k] = n
stack.append(n)
return [cache.get(n, -1) for n in nums1]