Count Elements Greater Than All Previous Elements

E · easyP · Verified PYQarrays

Given array of N integers, count elements strictly greater than ALL previous elements. First element always counts.

1<=N<=20, 1<=arr[i]<=10000
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.
← Chocolate Packets — Move Empty Packets to EndCount Even and Odd Numbers in Array →
Report an issue with this question