• + 0 comments

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

    public class Solution {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int l = scan.nextInt();   
    
        List<Integer> list = new ArrayList<>(l);
        for(int i = 0; i<l; i++){
            list.add(scan.nextInt());
        }
    
        int q = scan.nextInt();
    
        for(int i= 0; i<q; i++){
            String b = scan.next();
            if("Insert".equalsIgnoreCase(b)){
                int x = scan.nextInt();
                int y = scan.nextInt();  
                list.add(x, y);
            }
            if("Delete".equalsIgnoreCase(b)){
                int x = scan.nextInt();
                list.remove(x);
            }
        }
    
        list.forEach(i->{System.out.print(i+" ");});
        scan.close();
    }
    

    }