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.
You have a Sequence & Query. You create enough memory to store sequences. You then query the sequences and display the answers.
According to Code
You create enough memory to store Sequences & Queries since you do not know how many sequences and number of queries will be used. You use
**arr and *dummy
3 1 5 4
The first digit, 3, means the number of values in the sequence
arr[i] = new [3];
I then store the following values into the store arr[3] = {1, 5, 4}
I then create enough memory to store Query values
dummy = new int[numQueries];
since Query values are only two, 1 3
dummy[i][0] = 1
dummy[i][1] = 3
i means Query index
I then display the value of Sequence according to Query
dummy[0][1] = 0
dummy[1][1] = 1
arr[0][1] = 5
Variable Sized Arrays
You are viewing a single comment's thread. Return to all comments →
You have a Sequence & Query. You create enough memory to store sequences. You then query the sequences and display the answers.
You create enough memory to store Sequences & Queries since you do not know how many sequences and number of queries will be used. You use **arr and *dummy
3 1 5 4
The first digit, 3, means the number of values in the sequence arr[i] = new [3]; I then store the following values into the store arr[3] = {1, 5, 4}
I then create enough memory to store Query values dummy = new int[numQueries];
since Query values are only two, 1 3 dummy[i][0] = 1 dummy[i][1] = 3 i means Query index
I then display the value of Sequence according to Query dummy[0][1] = 0 dummy[1][1] = 1 arr[0][1] = 5
Formular to display
arr[dummy[i][0]][dummy[i][1]]