Quote: You are given n lines. In each line there are zero or more integers. You need to answer a few queries where you need to tell the number located in Yth position of Xth line.
Quote:Sample Input 5 5 41 77 74 22 44 1 12 4 37 34 36 52 0 3 20 22 33 5 1 3 3 4 3 1 4 3 5 5 Sample Output 74 52 37 ERROR! ERROR!
import java.util.*; public class Solution { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); ArrayList<Integer> al = new ArrayList<Integer>(); for(int i=0;i<n;i++){ int a = scan.nextInt(); al.add(a); for(int j=0;j<a;j++){ int b = scan.nextInt(); al.add(j,b); } } scan.close(); Iterator<Integer> itr = al.iterator(); while(itr.hasNext()){ System.out.print(itr.next()+" "); } } }
x
y
ArrayList<integer></integer>
ArrayList<arraylist<integer>></arraylist<integer>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)