Created
July 10, 2021 00:06
-
-
Save germanescobar/c37bbcf7b387e7e634145611195b38ad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dailyTemperatures = function(temperatures) { | |
const result = [] | |
for (let i=0; i < temperatures.length; i++) { | |
let pos = 0 | |
for (let j=i+1; j < temperatures.length && pos === 0; j++) { | |
if (temperatures[j] > temperatures[i]) pos = j | |
} | |
result.push(pos > 0 ? pos - i : 0) | |
} | |
return result | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment