#K34552. Buildings with Sunlight
Buildings with Sunlight
Buildings with Sunlight
You are given a row of n buildings, each with a specified height. The sun rises from the left (east side) and a building can see the sun if it is strictly taller than all the buildings to its left. The first building will always see the sun.
Your task is to determine how many buildings have an unobstructed view of the sun.
Example: For n = 5 and heights = [3, 7, 8, 3, 6], the buildings that can see the sun are 3, 7, and 8, so the output is 3.
inputFormat
The input consists of two lines. The first line contains a single integer n (1 ≤ n ≤ 105), representing the number of buildings. The second line contains n space-separated integers representing the heights of the buildings.
outputFormat
Output a single integer representing the number of buildings that can see the sun.
## sample5
3 7 8 3 6
3