Problem - Find Count of Elements Greater Than All Prior Elements
Given an integer array Arr of size N, the task is to find the count of elements whose value is greater than all of its prior elements.
Note: The 1st element of the array should always be considered in the count of the result.
Example
Arr[] = {7, 4, 8, 2, 9}
- 7 is the first element, so it is included in the result.
- 8 is greater than all its previous elements (7, 4).
- 9 is greater than all its previous elements (7, 4, 8, 2).
Since a total of 3 elements meet the condition, the output is 3.
Example 1
Input:
5 -> Value of N, represents size of Arr 7 -> Value of Arr[0] 4 -> Value of Arr[1] 8 -> Value of Arr[2] 2 -> Value of Arr[3] 9 -> Value of Arr[4]
Output:3
Example 2
Input:
5 -> Value of N, represents size of Arr 3 -> Value of Arr[0] 4 -> Value of Arr[1] 5 -> Value of Arr[2] 8 -> Value of Arr[3] 9 -> Value of Arr[4]
Output:5
Constraints
1 <= N <= 201 <= Arr[i] <= 10000