Created
March 25, 2019 19:36
-
-
Save ykdojo/8b601d4ad1265029979f1339c239d6e9 to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* @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