Question : for an input number N, return the minimum number possible K such that there are N distinct integers less than or equal to K with total XOR as 0. Example : for N = 4, minimum number possible is 5 as 2^3^4^5 = 0. How should we solve this?
1:26:02 . Suppose the question is modified and is asking to return the min XOR the number can have in the array with any other remaining number, for every index. Then, This Approach fails for array [ 8,9,11,10,7,14]. As minimum XOR of 7 will be with 14 giving XOR = 9. XOR of 7^8 = 15 so the original approach will give answer 15 but that is not true imo. How should we proceed with such question ?
Question : for an input number N, return the minimum number possible K such that there are N distinct integers less than or equal to K with total XOR as 0.
Example : for N = 4, minimum number possible is 5 as 2^3^4^5 = 0.
How should we solve this?
The first question , check if the ith bit is set or not, 0110 is six right , but given i=2, 1
1:26:02 .
Suppose the question is modified and is asking to return the min XOR the number can have in the array with any other remaining number, for every index.
Then,
This Approach fails for array [ 8,9,11,10,7,14]. As minimum XOR of 7 will be with 14 giving XOR = 9.
XOR of 7^8 = 15 so the original approach will give answer 15 but that is not true imo.
How should we proceed with such question ?
sir at first you are taking one mask '010' which is comming from left shift of '001' and after that we are doing bitwise and.
1:28:36 8^7=15 8^5=13 8^3=11 ?