Skip to content

Instantly share code, notes, and snippets.

@caglarorhan
Last active February 2, 2018 21:02
Show Gist options
  • Select an option

  • Save caglarorhan/6cb3bd11597957716cbb30d65afca64b to your computer and use it in GitHub Desktop.

Select an option

Save caglarorhan/6cb3bd11597957716cbb30d65afca64b to your computer and use it in GitHub Desktop.
WarmerTemperature-DistanceOfDay
/**
* @param {number[]} temperatures
* @return {number[]}
*/
var dailyTemperatures = function(temperatures) {
let outPut = [];
//let test=[];
const howMany = temperatures.length;
temperatures.forEach(function(i,index){
let count=1;
let isIt=false;
for(var xcv=index+1; xcv<=howMany-1;xcv++){
if(temperatures[index]<temperatures[xcv] && !isIt){
outPut.push(count);
//test.push([temperatures[index],temperatures[xcv]]);
isIt=true;
break;
}
count++;
}
if(!isIt){
outPut.push(0);
//test.push('Nothing bigger after me:'+temperatures[index])
}
});
return outPut;
//return test;
};
@caglarorhan
Copy link
Author

little bug

@caglarorhan
Copy link
Author

bug solved, test array added for output testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment