当前位置:网站首页>Stack -- 739 Daily temperature
Stack -- 739 Daily temperature
2022-06-29 05:49:00 【Follow the road to the end】
Given an array of integers temperatures , Indicates the daily temperature , Returns an array answer , among answer[i] It means in the i After heaven , Will have a higher temperature . If the temperature doesn't rise after that , Please use... In this position 0 Instead of .
Example 1:
Input : temperatures = [73,74,75,71,69,72,76,73]
Output : [1,1,4,2,1,1,0,0]
Example 2:
Input : temperatures = [30,40,50,60]
Output : [1,1,1,0]
Example 3:
Input : temperatures = [30,60,90]
Output : [1,1,0]
var dailyTemperatures = function (temperatures) {
const stack = [0]
let count = 1
const len = temperatures.length
const res = new Array(len).fill(0)
for(let i=1; i<len; i++) {
const num = temperatures[i]
while(num > temperatures[stack[count-1]]) {
const index = stack.pop()
res[index] = i -index
count--
}
stack.push(i)
count++
}
return res
};1
边栏推荐
- Would like to ask, which is the better choice for securities companies? I don't understand. Is it safe to open an account online now?
- Cloud native annual technology inventory is released! Ride the wind and waves at the right time
- QT precautions and RCC download address
- Test content
- The fresh student who was born in Ali after 2000: it's really fragrant to mend this
- Loosely matched jest A value in tohavebeencalledwith - loose match one value in jest toHaveBeenCalledWith
- Difference between parametric continuity and geometric continuity
- Conditional test, if and case conditional test statements of shell script
- Embedded RTOS
- CodeIgniter active record not equal - CodeIgniter active record not equal
猜你喜欢

Openfpga wishes you a happy Lantern Festival!

Ctrip launched the "3+2" office mode. Are you sour?

Analysis report on the investment market of the development planning prospect of the recommended rare earth industry research industry in 2022 (the attachment is a link to the online disk, and the rep

Use of sed in shell script

How to choose congestion model and anemia model

Research on heuristic intelligent task scheduling

5000+ word interpretation | Product Manager: how to do a good job in component selection?

Alibaba microservice component Sentinel

Analysis report on the investment market of the development planning prospect of the recommended wind power industry research industry in 2022 (the attachment is a link to the network disk, and the re

How to use thread stack location
随机推荐
Robot reinforcement learning -- first person vs third person
The fresh student who was born in Ali after 2000: it's really fragrant to mend this
Skills of writing test cases efficiently
Analysis of ArrayList set in teacher Yang's class
2,5-di (3,4-dicarboxyphenoxy) - 4 '- phenylethynylbiphenyldianhydride (pephqda) / Qiyue custom supply porphyrin modified amphiphilic block copolymer peg113-pcl46-porphyrin
证券开户安全么,有没有什么危险呢
Research Report on the recommended lithography industry in 2022 industry development prospect market investment analysis (the attachment is a link to the network disk, and the report is continuously u
Functions and arrays of shell scripts
Leetcode notes on question brushing (XIV) -- related topics of binary tree attributes in binary tree chapter
The first commercial spacewalk of mankind is finalized! Musk SpaceX announced a new round of space travel plan, and the American rich became repeat customers
On February 15, the market hot money operation and the dragon and tiger list
5000+ 字解读 | 产品经理:如何做好元器件选型?
patent filter
2022-02 Microsoft vulnerability notification
(practice C language every day) matrix
Will the order of where conditions in MySQL affect the union index? Will where 1 =1 affect the use of the index? Does where 1 =1 affect the use of indexes?
Multiline regular expression search in Visual Studio code - multiline regular expression search in Visual Studio code
5000+ word interpretation | Product Manager: how to do a good job in component selection?
Service grid ASM year end summary: how do end users use the service grid?
It turns out that the joys and sorrows of programmers are not interlinked