The teacher lined up N (1<=N<=1000) students. Write a program to find the number of students that the teacher standing in front can see when the heights of the students standing in a line are given in order from the front. (If it is larger than the people standing in front, it is visible, if it is smaller or equal to it, it is invisible.)
An integer N is entered in the first line. In the next row, the heights of N students are given in order from the front.
8
130 135 148 140 145 150 150 153
Prints the maximum number of students the teacher can see.
5
function solution(arr) {
let answer = 1,
max = arr[0];
for (let x of arr) {
if (x > max) {
answer++;
max = x;
}
}
return answer;
}