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.
int n,q;
int k,i=0;
cin>>n;
cin>>q;
int size_of_n=n;
int size_of_q=q;
//declaring arraay of pointers to hold the array
int **array1;
//array to hold the query answer
int *array2;
array1=(int **)malloc(n*sizeof(int*));
array2=(int *)malloc(q*sizeof(int));
while(n!=0)
{
cin>>k;
array1[i]=(int *)malloc((k+1)*sizeof(int));
array1[i][0]=k;
for(int j=1;j<k+1;j++)
{
cin>>array1[i][j];
}
//function(array1[i],k+1);
++i;
--n;
}
i=0;
while(q!=0)
{
int a,b;
cin>>a>>b;
array2[i]=array1[a][b+1];
--q;
i++;
}
for(int i=0;i<size_of_q;i++)
{
cout<<*(array2+i)<<endl;
}
for (int i = 0; i < size_of_n; ++i)
{
free(array1[i]);
}
free(array2);
return 0;
}
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 →
}