#C9814. Increasing Triplet Subsequence
Increasing Triplet Subsequence
Increasing Triplet Subsequence
Given a sequence of integers, determine if there exists an increasing subsequence of length three. In other words, check if there exist indices i, j, k such that 0 ≤ i < j < k < n and (nums[i] < nums[j] < nums[k]). You need to implement a solution that reads the input from the standard input (stdin) and writes the result to the standard output (stdout).
The input format is as follows:
- The first line contains a single integer n, the number of elements in the sequence.
- The second line contains n integers separated by spaces, representing the elements of the sequence.
The output should be a single line: either True
if an increasing triplet subsequence exists, or False
otherwise.
Note: If the number of elements is less than 3, the output should be False
.
inputFormat
The first line contains an integer n (n \geq 0) representing the number of elements in the sequence. The second line contains n space separated integers, which represent the sequence.
outputFormat
A single line containing either True or False indicating whether there exists an increasing subsequence of length three.## sample
5
1 2 3 4 5
True