#K91207. Triplet Subsequence
Triplet Subsequence
Triplet Subsequence
You are given an array of integers. Your task is to determine if there exists an increasing triplet subsequence in the array. In other words, check if there exist indices \(i, j, k\) such that \(i < j < k\) and \(a_i < a_j < a_k\). This problem is fundamental in algorithm design and tests your ability to process sequences with a greedy strategy.
Example:
Input: 6 2 1 5 0 4 6 Output: True
Note: The triplet should strictly follow the conditions described above.
inputFormat
The input begins with an integer \(n\) (\(n \geq 1\)) representing the number of elements in the array. The next line contains \(n\) space-separated integers.
outputFormat
Output a single line containing either True
or False
indicating whether there exists an increasing triplet \(a_i, a_j, a_k\) as per the condition \(a_i < a_j < a_k\) with \(i < j < k\).
6
2 1 5 0 4 6
True