不知道要打什麽,直接开始
题号:739 标题:Daily Temperatures 难度:Medium
Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature. If there is no future day for which this is possible, keep answer[i] == 0 instead.
我的程序码
class Solution {
public int[] dailyTemperatures(int[] temperatures) {
int[] result = new int[temperatures.length];
Arrays.fill(result, 0);
int i,j,k,count=0;
for(i=0;i<temperatures.length-1;i++){
count = 1;
if(temperatures[i]<temperatures[i+1]){
result[i] = 1;
continue;
}
for(j=i+1;j<temperatures.length;j++){
if(temperatures[i]<temperatures[j]){
result[i] = count;
break;
}
count++;
}
}
return result;
}
}
花比较久的时间
又是Time Limit Exceeded,我在第二层for前加上,if(temperatures[i]<temperatures[i+1])
判断,就过了!?
DAY21心得
我真的很常遇到Time Limit Exceeded,我想是我得思考还不够精准?真的很钦佩大神们都有很多更聪明的解法,慢慢学习罗
>>: Flutter体验 Day 28-flame JoystickComponent
摘要 交叉验证不同方法组合的模型准确率 1.1 参数说明 1.2 程序码 选择模型组合方法 2.1 ...
如果你是一个有野心且不安於现状的人,薪水谈判是你一定要去做的事情。 在阅读这篇文章前,你可以先思考...
将钱先放到你的金卡,可以享大大大优惠,点点卡、OO卡、XX卡、网咖等都是先储值再消费,这边将实作一个...
先备知识: 基本python能力 : 熟悉各基本型态,认识串列、字典、函式、class 了解深度学习...
每年生日刚好是伊豆诸岛的旺季开始前一周,通常天气宜人,海水清澈到可以目视钓鱼,离东京只要搭船三小时,...