Some error occured while loading page for you. Please try again.

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.

The calculated index is definied in the two bullet points:

xy: Insert y at the end of the ((x XOR lastans) mod N)th sequence

x y: Print the value of the (y mod size)th element of the ((x XOR lastans) mod N)th sequence. Here, size denotes the size of the related sequence. Then, assign this integer to lastans.

So given 2 squences (N=2), lastans=0 and 1 0 5 | {type = 1, x = 0, y = 5} you would apply operation #1 to 0 and 5: You would insert 5 at the end of the squence at the calculated index of ((0^0)%2)

Think of it like a hashmap with buckets: the sequences are buckets, and you are inserting a new collision at the end of the bucket's linked list.

Yep if N=2 then you would mod 2. Since I chose some of the same stuff as the practice problem I have now modified my answer to reflect two sequences instead of five for clarity.

for(int i=0; i<Q;i++)
{
long int k=A[i][0];
if(k==1)
{
long int x=A[i][1];
t=((x^lastAns)%N);
list[t][a[t]]=A[i][2];
a[t]++;}
else{
long int x=A[i][1];
t=((x^lastAns)%N);
long int y=A[i][2];
long int size= y % a[t];
lastAns=list[t][size];
cout<<lastAns<<endl;
}
} is the logic right here ?

GOD BLESS YOU, seriously, I read the description and the example so many times and could not figure out where the author gets values for x and y... Such a simple problem if you word it right

## Dynamic Array

You are viewing a single comment's thread. Return to all comments →

You just need to break it down into each part.

There is a dynamic array of sequences.

There are two types of queries:

one adds an element to a sequence at a calculated index

two finds the sequence at a calculated index and prints the value at the calculated subindex.

Thank you for the simplification. Can I ask what, precisely, you mean by a 'calculated index' though?

The calculated index is definied in the two bullet points:

`x`

`y`

: Insert`y`

at the end of the`((x XOR lastans) mod N)`

th sequence`x y`

: Print the value of the`(y mod size)`

th element of the`((x XOR lastans) mod N)`

th sequence. Here,sizedenotes the size of the related sequence. Then, assign this integer tolastans.So given 2 squences (

`N=2`

),`lastans=0`

and`1 0 5 | {type = 1, x = 0, y = 5}`

you would apply operation#1to`0`

and`5`

: You would insert 5 at the end of the squence at the calculated index of`((0^0)%2)`

Think of it like a hashmap with buckets: the sequences are buckets, and you are inserting a new collision at the end of the bucket's linked list.

Is it

`((0^0)%2)`

? as`N=2`

Yep if N=2 then you would mod 2. Since I chose some of the same stuff as the practice problem I have now modified my answer to reflect two sequences instead of five for clarity.

Thanks jensbodal, the hardest part of it was deciphering the extremly poorly worded question/explanation.

thank You very much " jensbodal "...

no its wrong u have to place the element right after its first one

Thank you clear explanation, the original problem statement is really ambigious.

I agree !

Thank you for the clarification!

Cheers mate..thanks for this explanation... I was going mad understanding the problem statement

thank you so much so for the description

Without your explainations i couldn't solve. Thank you @jensbodal.

GOD BLESS YOU, seriously, I read the description and the example so many times and could not figure out where the author gets values for x and y... Such a simple problem if you word it right

Have a confuse about task.

Q1: 1 x y

Find the sequence seqList, seq , at index ((x xor lasAns) % N)in seqList.

what is x, what is y? x, y not confirm, how we can get the index?

See post from "jensbodal" (6 months ago) - he explained x, y, etc.