Prompt: Given an integer array, nums, check if there is a triplet where nums[i] < nums[j] < nums[k] and i < j < k.
Example:
Input: nums = [1,2,3,4,5]
Output: true
Explanation: Any triplet where i < j < k is valid.
Input: nums = [5,4,3,2,1]
Output: false
Explanation: No triplet exists.
Input: nums = [2,1,5,0,4,6]
Output: true
Explanation: The triplet (3, 4, 5) is valid because nums[3] == 0 < nums[4] == 4 < nums[5] == 6.
Solution: We can solve this by looping through the integers and evaluating it as the third largest integer. We can save the previous second largest integer and first largest integer. We can initial the first and second integer with positive infinity. While we loop through each integer, we check if the current integer is smaller than the first integer and if that is true, we can save the current integer as the first integer. If the first check is completed, we can check if the second integer is smaller than the current number and if that is true, we can save the current integer as the second integer. If the second check is completed, then we can check if the first integer is smaller than the second integer and if the second integer is smaller than the current integer. If the final check is true, then we can return a True.
The runtime for this solution is O(n) since we just loop through all elements.