For this Question: In Newton City, there are N buildings in a line. A building is considered good if the height of the building is greater than or equal to all the buildings in its right side. 
Given the height of N buildings in the line, your task is to print the good buildings in the same order as they are given.

Note:- The rightmost building will always be good as their is no building in its right sideThe first line of input contains a single integer N. The next line of input contains N space- separated integers depicting the values of the array.

Constraints:-
1 <= N <= 100000
1 <= Arr[i] <= 100000Print all the good buildings as they appear in the array.Sample Input:-
6
3 7 4 1 2 1

Sample Output:-
7 4 2 1

Explanation:-
There is no greater element than 7 4 2 1 on their right side.

Sample Input:-
5
1 2 3 4 5

Sample Output:-
5, I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
	public static void main(String[] args)throws IOException {
        BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
        br.readLine();
        String[] line = br.readLine().split(" ");
        Stack<Integer> st = new Stack<>();

        int max = Integer.MIN_VALUE;

        for (int i=line.length-1;i>0;--i){
            int num = Integer.parseInt(line[i]);

            if(num >= max){
                st.push(num);
                max = num;
            }
        }

        while (!st.empty()){
            System.out.print(st.pop()+" ");
        }
    }
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?