mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 00:43:04 +08:00
@ -271,6 +271,7 @@ class Solution {
|
|||||||
```
|
```
|
||||||
|
|
||||||
Python:
|
Python:
|
||||||
|
> 未精简版本
|
||||||
|
|
||||||
```python
|
```python
|
||||||
class Solution:
|
class Solution:
|
||||||
@ -291,6 +292,21 @@ class Solution:
|
|||||||
return answer
|
return answer
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> 精简版本
|
||||||
|
|
||||||
|
```python
|
||||||
|
class Solution:
|
||||||
|
def dailyTemperatures(self, temperatures: List[int]) -> List[int]:
|
||||||
|
answer = [0]*len(temperatures)
|
||||||
|
stack = []
|
||||||
|
for i in range(len(temperatures)):
|
||||||
|
while len(stack)>0 and temperatures[i] > temperatures[stack[-1]]:
|
||||||
|
answer[stack[-1]] = i - stack[-1]
|
||||||
|
stack.pop()
|
||||||
|
stack.append(i)
|
||||||
|
return answer
|
||||||
|
```
|
||||||
|
|
||||||
Go:
|
Go:
|
||||||
|
|
||||||
> 暴力法
|
> 暴力法
|
||||||
|
Reference in New Issue
Block a user