Given an array of heights of N buildings in a row. You can start from any building and jump to the adjacent right building till the height of building to the right is less than or equal to the height of your current building. Find the maximum number of jumps you can make. Input First line of input contains a single integer N. Second line of input contains N integers, denoting the array height.
Constraints: 1 <= N <= 100000 1 <= height[i] <= 1000000000 Output Print the maximum number of jumps you can make.the program i tried
class Main {
public static void main (String[] args) {
// Your code here
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[]a = new int[n];
for(int i = 0; i<n; i++){
a[i] = sc.nextInt();
}
int count=1;
int max = a[0];
for(int i = 1; i<n; i++){
if(a[i] > max)
{
count++;
max = a[i];
}
}
System.out.println(count);