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, k, row, col;
cin>>n>>q;
//vector is dyanmic array which can increase size at runtime
//vector<vector<int>> is dynamic matrix which has n row and colume
//n is number of row
vector<vector<int>> a(n);
for (int i=0; i<n; i++) {
//k is the number of colume
cin>>k;
//resize(size) function will create array at index a[i] which has k number of element
a[i].resize(k);
//inserting value in matrix
for (int j=0; j<k; j++)
cin>>a[i][j];
}
//q is number of opration to perform on matrix
while(q--){
//get index's of matrix
cin>>row>>col;
cout<<a[row][col]<<endl;
}
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 →
int main() {
}