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.
publicstaticvoidmain(String[]args){/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */Scannerscanner=newScanner(System.in);intn=scanner.nextInt();HashMap<Integer,int[]>map=newHashMap<>();for(inti=1;i<=n;i++){intd=scanner.nextInt();int[]line=newint[d+1];for(intj=1;j<=d;j++){line[j]=scanner.nextInt();}map.put(i,line);}intq=scanner.nextInt();for(inti=1;i<=q;i++){intx=scanner.nextInt();inty=scanner.nextInt();try{System.out.println(map.get(x)[y]);}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 →