#C4652. Counting Strictly Increasing Triplets in an Array
Counting Strictly Increasing Triplets in an Array
Counting Strictly Increasing Triplets in an Array
Given an array of integers, your task is to count the number of contiguous subarrays (triplets) of length 3 that are strictly increasing. A triplet ( (a, b, c) ) is considered strictly increasing if ( a < b < c ).
For example, in the array [1, 2, 3, 1, 2, 3, 4] there are 3 such subarrays: [1, 2, 3], [2, 3, 1] (note: not increasing) and [3, 1, 2] (also not increasing), but the valid ones are [1, 2, 3] starting at the first and fifth positions and [2, 3, 4] starting at the fifth position, hence the answer is 3.
Solve the problem by reading input from standard input and writing the result to standard output.
inputFormat
The first line contains an integer ( n ) representing the number of elements in the array. The second line contains ( n ) space-separated integers denoting the elements of the array.
outputFormat
Output a single integer representing the count of contiguous subarrays of length 3 that are strictly increasing.## sample
7
1 2 3 1 2 3 4
3