We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9555e08 commit 08cad02Copy full SHA for 08cad02
problems/0503.下一个更大元素II.md
@@ -97,7 +97,18 @@ public:
97
Java:
98
99
Python:
100
-
+```python3
101
+class Solution:
102
+ def nextGreaterElements(self, nums: List[int]) -> List[int]:
103
+ dp = [-1] * len(nums)
104
+ stack = []
105
+ for i in range(len(nums)*2):
106
+ while(len(stack) != 0 and nums[i%len(nums)] > nums[stack[-1]]):
107
+ dp[stack[-1]] = nums[i%len(nums)]
108
+ stack.pop()
109
+ stack.append(i%len(nums))
110
+ return dp
111
+```
112
Go:
113
114
JavaScript:
0 commit comments