For this Question: You are given an integer array A of size N and an integer Q denoting the number of queries. Your task is to print the resultant array after applying the all queries. 
The queries can be of one of the four types.
"1" Remove the first element 
"2" Remove the second element 
"3" Remove the last element 
"4" Remove the second last element 
You can be sure that the queries are always possible.First line contains an integer N - the size of array
Next line contains N space separated integers
Next line contains an integer q - the number of queries
Next line contains Q space separated integers - denoting the type of the query. These integers are in the range of 1 to 4

Constraints
1 <= N <= 100000
1 <= Ai <= 100000
1 <= Q <= 100000Print a line containing a single integer m denoting the size of array after applying all queries.
Next line should contain m space separated integers denoting the array after applying all queries.Sample Input 1:
5
1 2 3 4 5
3 
1 4 2

Output:
2
2 5

Explanation:
Initial array = { 1, 2, 3, 4, 5 }
Remove the first element = { 2, 3, 4, 5 }
Remove the second last element = { 2, 3, 5 }
Remove the second element = { 2, 5 }

Sample Input 2:
3
1 2 3
1 
1 

Output:
2
2 3

Explanation:
Initial array = { 1, 2, 3 }
Remove the first element = { 2, 3 }, I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
                      int n = sc.nextInt();

                      int [] arr =new int[n];
                      for(int i=0;i<n;i++){
                          arr[i]=sc.nextInt();
                      }
                      int q = sc.nextInt();
                        int size = n;
                        int front=0;
                        int end=n-1;
                      while(q-->0){
                          int x = sc.nextInt();

                          if(x==1){
                              front++;
                                size--;
                          }
                          else if(x==2){
                              arr[front+1]=arr[front];
                              front++;
                              size--;
                              }
                            else if(x==3){
                                end--;
                                size--;

                            }
                            else if(x==4){
                                arr[end-1]=arr[end];
                                end--;
                                size--;
                            }
                      }
                      System.out.println(size);

                      for(int i=front;i<=end;i++){
                          System.out.print(arr[i]+" ");
                      }
    }
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?