Question: Java8: import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { /* * Complete the function below. */ static void superStack(String[]
Java8:

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
/*
* Complete the function below.
*/
static void superStack(String[] operations) {
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int operations_size = 0;
operations_size = Integer.parseInt(in.nextLine().trim());
String[] operations = new String[operations_size];
for(int i = 0; i
String operations_item;
try {
operations_item = in.nextLine();
} catch (Exception e) {
operations_item = null;
}
operations[i] = operations_item;
}
superStack(operations);
}
}
Implement a stack that accepts the following commands and performs the operations described: push v. Push integer vonto the top of the stack pop: Pop the top element from the stack inci v. Add v to each of the bottom i elements of the stack After each operation, print the value at the top of the stack. If the stack is empty, print the string 'EMPTY
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
