• + 0 comments

    java solution

    import java.io.; import java.util.;

    public class Solution {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        s.nextLine();
        Queue<Integer> q=new LinkedList<>();
        while(n-->0){
            String str=s.nextLine();
            if(str.startsWith("1")){
                int val= Integer.parseInt(str.split(" ")[1]);
                q.add(val);
            }
            else if(str.equals("2")){
              if(!q.isEmpty())  q.remove();
            }
           else {
            if(!q.isEmpty())
    
            System.out.println(q.peek());
           }
        }
    }
    

    }