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.
i tried to explain as much as i can, hope this helps.
#include<cmath>#include<cstdio>#include<vector>#include<iostream>#include<algorithm>usingnamespacestd;intmain(){/* defining the variables n : size of main array q : number of queries k : size of a given array in the main one */intn,q,k;cin>>n>>q;/* creating the main array of n elements, which is an array of pointers to the others arrays (can't create a 2 dimentional array since the arrays within "a" are not the same size) */int**a=newint*[n];//for each element in array afor(inti=0;i<n;i++){cin>>k;//creating a new array inside of the array aa[i]=newint[k];//filling the array with valuesfor(intj=0;j<k;j++){cin>>a[i][j];}}// executing the queriesfor(intl=0;l<q;l++){inti,j;// putting the values in the variables i and jcin>>i>>j;cout<<a[i][j]<<"\n";}return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Variable Sized Arrays
You are viewing a single comment's thread. Return to all comments →
i tried to explain as much as i can, hope this helps.