Bit Manipulation Interview Problems Solved Step by Step | Competitive Programming | Data Structures

Поділитися
Вставка
  • Опубліковано 27 лис 2024

КОМЕНТАРІ • 5

  • @shivamrastogi3154
    @shivamrastogi3154 2 роки тому +1

    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?

  • @phardik5610
    @phardik5610 10 місяців тому

    The first question , check if the ith bit is set or not, 0110 is six right , but given i=2, 1

  • @shivamrastogi3154
    @shivamrastogi3154 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 ?

  • @rajdipdas1329
    @rajdipdas1329 2 роки тому

    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.

  • @rahultoshniwal1533
    @rahultoshniwal1533 2 роки тому

    1:28:36 8^7=15 8^5=13 8^3=11 ?