#K14101. Buildings with Sunlight
Buildings with Sunlight
Buildings with Sunlight
You are given a row of n buildings, where the height of each building is given in order from left to right. A building receives sunlight if it is taller than all the buildings to its left. Formally, for a building with height \(h_i\), it receives sunlight if and only if \(h_i > \max{\{h_1, h_2, \dots, h_{i-1}\}}\). The task is to determine how many buildings will receive sunlight.
Input Format: The first line contains an integer n (the number of buildings). The second line contains n space-separated integers representing the heights of the buildings.
Output Format: Output a single integer representing the number of buildings that receive sunlight.
Example:
Input: 5 3 1 4 2 5</p>Output: 3
In this example, the buildings with heights 3, 4, and 5 receive sunlight.
inputFormat
The first line of input contains a single integer (n) denoting the number of buildings. The second line contains (n) space-separated integers representing the heights of the buildings in order from left to right.
outputFormat
Output a single integer that is the count of buildings which receive sunlight.## sample
5
3 1 4 2 5
3