Daily Leetcode Challenge |NOV 8 | HINDI | Maximum XOR for Each Query

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

КОМЕНТАРІ • 3

  • @darshankumar5546
    @darshankumar5546  9 годин тому

    class Solution:
    def getMaximumXor(self, nums: List[int], maximumBit: int) -> List[int]:
    xorResult=nums[0]
    for i in nums[1:]:
    xorResult=xorResult^i

    n=len(nums)
    #print(xorResult,bin(xorResult)[2:])
    answer=[]
    for i in range(n):
    binaryResult=bin(xorResult)[2:]
    print('xor result=',xorResult,'In binary:',binaryResult)
    if(len(binaryResult)

  • @darshankumar5546
    @darshankumar5546  9 годин тому

    ENGLISH VIDEO: ua-cam.com/video/ULpo9XqI31c/v-deo.htmlsi=GdDOnxZPFQSxxIYJ

  • @darshankumar5546
    @darshankumar5546  9 годин тому

    # let a=101
    # a xor b should be max
    # ie a xor b = 111
    # then b= 010
    # a^b=k
    # k^b=a
    # k^a=b
    # #example 2 tracing
    # xor result= 2 In binary: 10
    # writing xorResult in maximumBits 010
    # after negating xor result: 101
    # [5]
    # removed element: 7
    # xor result= 5 In binary: 101
    # writing xorResult in maximumBits 101
    # after negating xor result: 010
    # [5, 2]
    # removed element: 4
    # xor result= 1 In binary: 1
    # writing xorResult in maximumBits 001
    # after negating xor result: 110 =4+2+0=6
    # [5, 2, 6]
    # removed element: 3
    # xor result= 2 In binary: 10
    # writing xorResult in maximumBits 010
    # after negating xor result: 101
    # [5, 2, 6, 5]
    # removed element: 2