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;
// get number of arrays and queries from input
cin >> n >> q;
//Create vector of n number of vectors
vector<vector<int>> vec(n);
//get input for number of entries in first vector
//add following input to vector
int numEntries, num;
for (int i = 0; i < n; i++) {
cin >> numEntries;
for (int j = 0; j < numEntries; j++) {
cin >> num;
vec[i].push_back(num);
}
}
//get from input the query location for q number of queries
//print to screen
int first, second;
for (int i = 0; i < q; i++) {
cin >> first >> second;
cout << vec[first][second] << 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 →
include
include
include
include
include
using namespace std;
int main() {
}