MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / main

Function main

Hackerrank_problems/Variablesize_array/Solution.cpp:12–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10
11
12int main() {
13
14 int n, q ,k;
15 cin >> n >> q;
16 int a[n];
17 int **arr = new int*[n];
18 for(int i = 0; i < n; i++) {
19 cin >> k;
20 a[i] = k;
21 arr[i] = new int[k];
22 for(int j = 0; j < k; j++) {
23 cin >> arr[i][j];
24 }
25 }
26 for(int i = 0; i < q; i++) {
27 int p, q;
28 cin >> p >> q;
29 cout << arr[p][q] << endl;
30 }
31 return 0;
32}
33// used 'new' opeator for dynamic memory allocation ,if you check out the problem statement
34// you will encounter that the array elements are not taken in a continuous manner form the input
35// first the size of the 1D array is given and then the array elemnts

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected