MaxAnd Problem

Given 2 numbers X and Y find value of max (P&Q) such thatX<=P<Q<=Y
Question asked in delhivery interview
Pls help

Constraints on X and Y?

10^18 are constraints

answer would be max((Y-1)&Y,(Y-1)&(Y-2))

If Y is odd then the answer is (Y-1)&Y
if Y is even then the answer is (Y-1)&(Y-2)
:grinning::grinning:

@s5960r @akshat_165
Is my solution right?

1 Like