@@ -0,0 +1,1540 @@
+//https://www.hackerrank.com/challenges/maximum-element%0Aimport java.io.*;%0Aimport java.util.*;%0A%0Apublic class Solution %7B%0A    public static void main(String%5B%5D args) throws IOException %7B%0A        final StringBuffer sb = new StringBuffer();%0A        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));%0A        %0A        //For each query...%0A        int max = 0;%0A        final Deque%3CStackEntry%3E stack = new ArrayDeque%3CStackEntry%3E();%0A        for(int N = Integer.parseInt(br.readLine()); N %3E 0; --N)%7B%0A            %0A            //Get input%0A            final String%5B%5D line = br.readLine().split(%22 %22);%0A            final byte type = Byte.parseByte(line%5B0%5D);%0A            %0A            //Push a new element onto the stack, keeping track of current max%0A            if(type == 1)%7B%0A                final int x = Integer.parseInt(line%5B1%5D);%0A                stack.push(new StackEntry(x, (x %3E max) ? max = x : max));%0A            %0A            //Delete the top element of the stack%0A            %7D else if(type == 2)%7B%0A                stack.pop();%0A                max = (stack.isEmpty()) ? 0 : stack.peek().max;%0A            %0A            //Print the maximum element in the stack%0A            %7D else if(type == 3)%7B%0A                sb.append(max + %22%5Cn%22);%0A            %7D%0A        %7D%0A        System.out.print(sb);%0A    %7D%0A    %0A    private static class StackEntry%7B%0A        public final int val;%0A        public final int max;%0A        public StackEntry(final int val, final int max)%7B%0A            this.val = val;%0A            this.max = max;%0A        %7D%0A    %7D%0A%7D%0A

Create maximum-element.java