You are viewing a single comment's thread. Return to all comments →
Scanner sc=new Scanner(System.in); int n=sc.nextInt(); ArrayList> list=new ArrayList>();
for(int i=0;i<n;i++){ int l1=sc.nextInt(); ArrayList<Integer> arr=new ArrayList<Integer>(); for(int j=0;j<l1;j++){ arr.add(sc.nextInt()); } list.add(arr); } int q=sc.nextInt(); for(int i=0;i<q;i++){ int a=sc.nextInt()-1; int b=sc.nextInt()-1; if(a<list.size() && a>=0){ if(b<(list.get(a).size()) && b>=0){ System.out.println(list.get(a).get(b)); } else{ System.out.println("ERROR!"); } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Java Arraylist
You are viewing a single comment's thread. Return to all comments →
Scanner sc=new Scanner(System.in); int n=sc.nextInt(); ArrayList> list=new ArrayList>();