In this solution i tried to make both current number and previous number as bit arrays and tried to find the bits where if in 1st array , the bit is 1 and in the 2nd the bit is also one , there are 2 ways of selecting(0&1) and if bit in 1st array is 1 and in second array is 0 , then ans must be 0. Please find the error.

Did you consider the case when answer will be zero?
it was mentioned in the question that B may not have been formed from any A sequence ?

The answer in that case will be 0.
More specifically, if at any position i… for any bit j B[i] has jth bit 0 but B[i-1] has jth bit 1…then answer is 0.

1 Like

FML. I read it as it is guaranteed that array B is formed from any sequence A :pensive:
Just skipped “not”


At least you read it somehow…I completely rushed the fuck up when I thought it was too easy and I should solve it FAST!!!..XD result = 1WA :joy:


Ya i think so , i thought the answer to be zero if the current number and previous number bits are 0 & 1 respectively.

Like in:
6-> 110
As the second bit from last in 13 is 0 and second last bit of 6 is 1 , this isnt possible .Hence answer is 0

1 Like

8 1 1 3 3

I compared my and your solution and this is one of the test cases where your code fails

and even on this …

8 1

I have not checked the condition where v[i]<v[i-1] and hence it fails to give 0. :pensive:

Same :no_mouth:

i had several WA attempts then figured we need to handle the case of improper input. The problem statement didn’t provide what should be given as output in the case of improper input so I assumed it to be zero.
Interesting part is … I corrected the code and checked the condition where arr[i]<arr[i-1] and got an AC.
but for the input say
15 16
i got output as 16 but the output should be 0 as it is not a valid sequence but my code passed and got an AC during contest XD
the input case test file during the contest didn’t cover this case I guess ?

1 Like