We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
importjava.util.*;publicclassmain{publicstaticvoidmain(String[]args){/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */Scannersc=newScanner(System.in);List<Integer>seq;List<List<Integer>>collect=newArrayList<>();inttot=sc.nextInt();for(inti=0;i<tot;i++){intsize=sc.nextInt();seq=newArrayList<>();for(intj=0;j<size;j++){seq.add(sc.nextInt());}collect.add(seq);}//System.out.println(collect);intquery=sc.nextInt();for(intk=0;k<query;k++){intx=sc.nextInt();inty=sc.nextInt();try{System.out.println(collect.get(x-1).get(y-1));}catch(Exceptione){System.out.println("ERROR!");}}}}
Cookie support is required to access HackerRank
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 →