Playing with cards

Sir I am not able to understand the question .would you please explain

@Megha2468
here we are given an array arranged in form stack like a0, a1, a2, a3, a4 where a4 is top and a0 is bottom of stack
we are also given q iterations where i=1 to q, in ith iteration we need to check something(explained below) by using ith prime number.
for eg:- Given q=5, then we need to consider 2,3,5,7,11 where these are 1st, 2nd … 5th prime numbers.

so taking the example now
5 2
3 4 7 6 5
here q is 2.
so iterations i are from 1 to 2.

i=1
starting from top i.e. initially 3,4,7,6, 5 <- TOP so check it if is divisible by 2 i.e. first prime. put it in B1 else in Ai i.e. some temporary stack.(because after this iteration i, that stack will be used for furthur work and this stack A will be of no use, so at the end of this iteration just we can swap that temp stack and stack A elements)
so we will take one by one from 5,6,7,4 then 3 and check if they are divisible by 2 then put in B1 else temp stack.
at end
B1 - 6, 4 <- TOP
temp - 5, 7, 3

i=2
we will start from the temp stack’s top and check with second prime i.e. 3
so start check from 3 then 7 then 5.
finally
B2 - 3
temp - 7, 5

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.