Created
May 5, 2019 05:32
-
-
Save lazycipher/beb134ff2ed582858db7cc3d1ff560b6 to your computer and use it in GitHub Desktop.
Variable Sized Array [HackerRank Practice]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cmath> | |
#include <cstdio> | |
#include <vector> | |
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
int main() { | |
int n, q, indexA, indexI; | |
//input size of array and no of queries | |
cin>>n>>q; | |
vector<int> a[n]; | |
for(int i=0; i<n; i++){ | |
//Get no. of Inputs in ins and get the value of array val. | |
int ins, val; | |
cin>>ins; | |
for(int j=0; j<ins; j++){ | |
cin>>val; | |
//Push back val to the array at a[i] | |
a[i].push_back(val); | |
} | |
} | |
for(int i=0; i<q; i++){ | |
cin>>indexA>>indexI; | |
cout<<a[indexA][indexI]<<"\n"; | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment