We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
根据每日 气温 列表,请重新生成一个列表,对应位置的输出是需要再等待多久温度才会升高超过该日的天数。如果之后都不会升高,请在该位置用 0 来代替。
气温
0
例如,给定一个列表 temperatures = [73, 74, 75, 71, 69, 72, 76, 73],你的输出应该是 [1, 1, 4, 2, 1, 1, 0, 0]。
temperatures = [73, 74, 75, 71, 69, 72, 76, 73]
[1, 1, 4, 2, 1, 1, 0, 0]
提示:气温 列表长度的范围是 [1, 30000]。每个气温的值的均为华氏度,都是在 [30, 100] 范围内的整数。
[1, 30000]
[30, 100]
The text was updated successfully, but these errors were encountered:
/** * @param {number[]} T * @return {number[]} */ var dailyTemperatures = function(T) { const result = new Array(T.length).fill(0); const stack = []; for (let i = 0; i < T.length; i++) { while (stack.length !== 0 && T[stack[stack.length - 1]] < T[i]) { const d = stack.pop(); result[d] = i - d; } stack.push(i); } return result; };
function dailyTemperatures(T: number[]): number[] { const result: number[] = new Array(T.length).fill(0); const stack: number[] = []; for (let i = 0; i < T.length; i++) { while (stack.length !== 0 && T[stack[stack.length - 1]] < T[i]) { const d = stack.pop() as number; result[d] = i - d; } stack.push(i); } return result; }
Sorry, something went wrong.
No branches or pull requests
739. Daily Temperatures
根据每日
气温
列表,请重新生成一个列表,对应位置的输出是需要再等待多久温度才会升高超过该日的天数。如果之后都不会升高,请在该位置用0
来代替。例如,给定一个列表
temperatures = [73, 74, 75, 71, 69, 72, 76, 73]
,你的输出应该是[1, 1, 4, 2, 1, 1, 0, 0]
。提示:
气温
列表长度的范围是[1, 30000]
。每个气温的值的均为华氏度,都是在[30, 100]
范围内的整数。The text was updated successfully, but these errors were encountered: