we have given two number A and B . we have to find a number X such that
- A XOR X is minimum
- number of set bit in X is equal to number of set bit in B
we have given two number A and B . we have to find a number X such that
Link to original problem? Presumably it doesn’t just trail off mid-sentence like this
DELETE ASAPPPPP
Post the entire question
Please correct that i am right or wrong
My App.
Any sample test case with sample output?
sample input
5 3
sample output
5
sample input
7 3
sample output
6
is this from any ongoing contest ?
If this from any Ongoing contest. We should not discuss.
this question asked in AppPerfect Pvt. Ltd. on campus recruitment drive
NO , take an example:
A = 43 = 101011
B = 3 = 000011
Now nA = 4 , nB = 2
nA>nB so according to your approach remove 2 set bits from right side of A then A = 1010 ie., 10
Now 43 ^ 10 = 33 which is not minimum instead of this we can unset the last diff bits in A
so A = 101000 ie., 40 now 43 ^ 40 = 3 which is minimum
@l_returns @anon55659401 Please see this i m correct or not?
Not from any ongoing challenge
yeah,same i was thinking!
which college?
See my example ?
Remove means unset the bit . Change from 1 to 0
College of technology and engineering , udaipur
Oh then it will be fine , i wrote bcz in first case u said we have to remove , in second case u said unset to set
There my mean is to unset . Sorry for that