1 개요[ | ]
- HR자바 Java List
Java
Copy
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 sc = new Scanner(System.in);
int N = sc.nextInt();
ArrayList<Integer> list = new ArrayList<Integer>();
for(int i=0; i<N; i++) {
list.add(sc.nextInt());
}
int Q = sc.nextInt();
for(int i=0; i<Q; i++) {
String query = sc.next();
if( query.equals("Insert") ) {
int x = sc.nextInt();
int y = sc.nextInt();
list.add(x, y);
continue;
}
if( query.equals("Delete") ) {
int x = sc.nextInt();
list.remove(x);
continue;
}
}
System.out.println( list.toString().replaceAll("[^0-9 ]","") );
}
}
2 같이 보기[ | ]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.