next greater element i

🏠
 1 class Solution:
 2     def nextGreaterElement(self, A: List[int], B: List[int]) -> List[int]:
 3         pos = {v:i for i,v in enumerate(B)}
 4         out = [-1]*len(A)
 5         for i, a in enumerate(A):
 6             for b in B[pos[a]+1:]:
 7                 if b > a:
 8                     out[i] = b
 9                     break
10         return out