Skip to content

Instantly share code, notes, and snippets.

@ykdojo
Created March 25, 2019 19:36
Show Gist options
  • Save ykdojo/8b601d4ad1265029979f1339c239d6e9 to your computer and use it in GitHub Desktop.
Save ykdojo/8b601d4ad1265029979f1339c239d6e9 to your computer and use it in GitHub Desktop.
/**
* @param {number[]} nums
* @return {boolean}
*/
var increasingTriplet = function(nums) {
let currentMin = nums[0];
let minWithSmaller = Infinity;
for (let i = 1; i < nums.length; i++) {
if (nums[i] > minWithSmaller) {
return true;
}
if (nums[i] > currentMin) {
if (nums[i] < minWithSmaller) {
minWithSmaller = nums[i];
}
}
if (nums[i] < currentMin) {
currentMin = nums[i]
}
}
return false;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment