As reported: Nutanix MTS-2 (June 2025), round 1 DSA: Increasing Triplet Subsequence — brute force, a sub-optimal approach and the optimal
O(N)one were discussed; running code was required, had one bug that was fixed, and passed the edge cases.
Given an integer array nums, return true if there exist indices i < j < k with nums[i] < nums[j] < nums[k], else false. This is LeetCode 334 — Increasing Triplet Subsequence.
Example 1
nums = [1,2,3,4,5] -> true
Example 2
nums = [5,4,3,2,1] -> false
Constraints: 1 ≤ nums.length ≤ 5 · 10^5; values fit in 32 bits. Aim for O(n) time and O(1) space.
Code runner format: one JSON value: nums (LeetCode's format). Implement increasingTriplet(nums); the harness prints true or false.