Count Elements Greater Than All Previous Elements
E · easyP · Verified PYQarrays
Problem
Given array of N integers, count elements strictly greater than ALL previous elements. First element always counts.
Constraints
1<=N<=20, 1<=arr[i]<=10000
Example
Input
5 7 4 8 2 9
Output
3
Track running max. Count++ whenever element > max_so_far, update max.
arr=[7,4,8,2,9]. 7=first(count), 8>7(count), 9>8(count). Total=3.