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 来代替。 例如,给定一个列表 temperatures = [73, 74, 75, 71, 69, 72, 76, 73],你的输出应该是 [1, 1, 4, 2, 1, 1, 0, 0]。 提示:气温 列表长度的范围是 [1, 30000]。每个气温的值的均为华氏度,都是在 [30, 100] 范围内的整数。
请根据每日 气温 列表,重新生成一个列表。对应位置的输出为:要想观测到更高的气温,至少需要等待的天数。如果气温在这之后都不会升高,请在该位置用 0 来代替。
例如,给定一个列表 temperatures = [73, 74, 75, 71, 69, 72, 76, 73],你的输出应该是 [1, 1, 4, 2, 1, 1, 0, 0]。
提示:气温 列表长度的范围是 [1, 30000]。每个气温的值的均为华氏度,都是在 [30, 100] 范围内的整数。
数组遍历
javascript
/** * @param {number[]} T * @return {number[]} */ var dailyTemperatures = function(T) { var res = [], len = T.length; for (var i = 0; i < len; i++) { var wait = 0; for (var j = i + 1; j < len; j++) { if (T[j] > T[i]) { wait = j - i; break; } } res.push(wait); } return res; };
go
func dailyTemperatures(T []int) []int { res := make([]int, 0) length := len(T) for i := 0; i < length; i++ { var wait int = 0 for j := i + 1; j < length; j++ { if T[j] > T[i] { wait = j - i break } } res = append(res, wait) } return res }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
习题
思路
数组遍历
解答
javascript
go
The text was updated successfully, but these errors were encountered: