We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 57168b7 commit 8f1679aCopy full SHA for 8f1679a
LeetCode/nextGreaterElement-1.py
@@ -0,0 +1,15 @@
1
+from collections import deque
2
+class Solution(object):
3
+ def nextGreaterElement(self, nums1, nums2):
4
+ """
5
+ :type nums1: List[int]
6
+ :type nums2: List[int]
7
+ :rtype: List[int]
8
9
+ s = deque()
10
+ d = {}
11
+ for i in nums2:
12
+ while s and s[-1] < i:
13
+ d[s.pop()] = i
14
+ s.append(i)
15
+ return [d[i] if i in d else -1 for i in nums1]
0 commit comments