Not getting the question,can u please explain.
https://online.codingblocks.com/player/14530/content/5461/4980
Playing with cards problem
Hi Animesh,
Consider the input is :
5 1
3 4 7 6 5
In this input Q is 1 so ther is only 1 iteration. Now there are three stacks intially:
A0 - [3, 4,7, 6, 5]
A1 - []
B1 - []
In first iteration we will look in stack A(iteration - 1) i.e. A0 and check whether the number is divisible by iteration th prime number i.e. 1st prime number i.e. 2 and if it is divisible then we add it in B(iteration) i.e. B1 stack else A(iteration) i.e. A1 stack. SO after first iteration the three stacks will look like this:
A0 - []
A1 - [5, 7, 3]
B1 - [6, 4]
Now since the Q is so we will not iterate further and print the B1,…,BQ, and AQ stack. Therefore, we first print B1 from top to bottom then A1 from top to bottom and hence the result:
4
6
3
7
5