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.
what we have here is an array of array sometimes called a jagged array.
think of it as vector of vectors.
each element in arr[i] has an array of integers.
the size of each inner array can vary.
INPUT:
first line has two integers n, q
then you have n lines describing each array:
k a[ i ][ 0 ] a[ i ][ 1 ] ... a[ i ][ k-1 ]
where k is the length of the array followed by k integers for array i.
then you have q lines of queries i, j
i = index of the array in the outer vector
j = index of the inner array in i
Task:
for each query, print the value at arr[ i ] [ j ].
Hence the problem known as variable sized array.
I would recommend to understand the code but not copy paste it in your editor. once you understand the code then dry run it and then write the algorithm of it in your copy and then try yourself to solve the question here. that is the best way to do it.
Variable Sized Arrays
You are viewing a single comment's thread. Return to all comments →
Let me explain the question for you.
INPUT:
then you have q lines of queries i, j i = index of the array in the outer vector j = index of the inner array in i
Task: for each query, print the value at arr[ i ] [ j ].
Hence the problem known as variable sized array.
I would recommend to understand the code but not copy paste it in your editor. once you understand the code then dry run it and then write the algorithm of it in your copy and then try yourself to solve the question here. that is the best way to do it.
If you like it then upvote . It is better for the coding community