You are viewing a single comment's thread. Return to all comments →
Thanks, but there is no need for three seperate for loops at the end. You can do all of that in one loop. Something like this:
int numSequence,numQueries, k; cin >> numSequence >> numQueries; // sequence int** array = new int*[numSequence]; // query int** query = new int*[numQueries]; for(int i=0;i<numSequence;i++){ cin >> k; array[i] = new int[k]; for (int j=0;j<k;j++){ cin >> array[i][j]; } } for(int i = 0; i<numQueries;i++){ query[i] = new int[2]; cin >> query[i][0] >> query[i][1]; cout << array[query[i][0]][query[i][1]] << endl; } return 0; }
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 →
Thanks, but there is no need for three seperate for loops at the end. You can do all of that in one loop. Something like this: