Professional Documents
Culture Documents
Adisa
Adisa
Nim :1910512112
Kelas : S1 Sistem Informasi Kelas D 19
import java.util.Scanner;
import java.util.Stack;
if (type == 1) {
int x = sc.nextInt();
elements.push(new Element(x, Math.max(elements.empty() ?
Integer.MIN_VALUE : elements.peek().max, x)));
} else if (type == 2) {
elements.pop();
} else {
System.out.println(elements.peek().max);
}
}
sc.close();
}
}
class Element {
int x;
int max;