Possible or not || CodeChef Starters 94 Solution with Explanation

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 พ.ย. 2024

ความคิดเห็น • 23

  • @anmolthind9646
    @anmolthind9646 ปีที่แล้ว

    Great work thanks alot bhaiya app itni easily explain kar dete hai tough question bi

  • @thesoftwareguy2183
    @thesoftwareguy2183 ปีที่แล้ว +2

    From where you have learn about SuperMask property ???

  • @md.asrafulhasan8217
    @md.asrafulhasan8217 ปีที่แล้ว

    tnx bro for this new trick.

  • @thesoftwareguy2183
    @thesoftwareguy2183 ปีที่แล้ว +1

    Its Damn easy !!
    Thankyou So much !!
    From where you have learn about SuperMask property ???

    • @learn_to_code10
      @learn_to_code10  ปีที่แล้ว

      Geeks for geeks Bitmasking or you can also search bit tricks for cp😁

  • @ekanshsharma1309
    @ekanshsharma1309 ปีที่แล้ว

    bhaiya bohot achha explaination tha. Please keep continue these type of question. Xor bitwise waale questions samjh nhi aate. Please suggest some material

  • @pranavmittal2976
    @pranavmittal2976 ปีที่แล้ว

    bro your explaination is just fabulous have no words ......☺☺☺

  • @Name-p1x
    @Name-p1x ปีที่แล้ว

    Can you pls post other question solutions also

  • @RaviRaj-xq7sv
    @RaviRaj-xq7sv ปีที่แล้ว

    bro subsequence too 1 size ka bhi ho sakta ha too jab ek element mil gaya fhir kyu check krna

  • @vinayaksharma7134
    @vinayaksharma7134 ปีที่แล้ว

    ❤❤

  • @atulyakumariit-indore2908
    @atulyakumariit-indore2908 ปีที่แล้ว

    great explanation.... but i had a doubt... wo and =-1 waala part samajh nai aaya and baadme hum and ke saath a[i] ka & kyu kar rahe hai?

    • @learn_to_code10
      @learn_to_code10  ปีที่แล้ว +2

      Now, let's break down the code:
      int And = -1;: The variable And is initialized to -1. In binary representation, -1 is all 1s (in two's complement form). This is done because we are going to use And to compute the bitwise AND of certain numbers. Initializing it to -1 ensures that the first bitwise AND operation does not change the result.
      if((a[i] & k) == k): Here, the code is checking if a[i] is a supermask of k. It's using the property of bitwise AND that if x & y = y, then x is a supermask of y. If this condition is true, then a[i] is a supermask of k.
      And &= a[i];: If a[i] is a supermask of k, the code computes the bitwise AND of And and a[i] and stores the result back in And. It's trying to keep track of the bitwise AND of all supermasks of k in the array.
      if(And == k): At the end, if the bitwise AND of all supermasks is k, it means there's a subsequence whose bitwise AND equals k, so it prints "YES". Otherwise, it prints "NO".
      In summary, And = -1; is used to initialize And in such a way that the first bitwise AND operation with it doesn't affect the result. And And &= a[i]; is used to compute the bitwise AND of all supermasks of k.

    • @atulyakumariit-indore2908
      @atulyakumariit-indore2908 ปีที่แล้ว

      @@learn_to_code10 oooh thank you for your efforts...i understood now...btw do you have any telegram channel...so that you dont need to type that all and just simply can send a voice note.

  • @RAMKUMAR-eb1kq
    @RAMKUMAR-eb1kq ปีที่แล้ว

    do it in english bro

  • @atulyakumariit-indore2908
    @atulyakumariit-indore2908 ปีที่แล้ว +1

    suscriber++;

  • @thumatibhavani9375
    @thumatibhavani9375 ปีที่แล้ว +1

    Bro please explain in english too

    • @learn_to_code10
      @learn_to_code10  ปีที่แล้ว

      You do not know hindi?

    • @thumatibhavani9375
      @thumatibhavani9375 ปีที่แล้ว

      Yes I don't know I am from telugu state..can you tell me the binary value for -1

    • @learn_to_code10
      @learn_to_code10  ปีที่แล้ว

      @@thumatibhavani9375 Now, let's break down the code:
      int And = -1;: The variable And is initialized to -1. In binary representation, -1 is all 1s (in two's complement form). This is done because we are going to use And to compute the bitwise AND of certain numbers. Initializing it to -1 ensures that the first bitwise AND operation does not change the result.
      if((a[i] & k) == k): Here, the code is checking if a[i] is a supermask of k. It's using the property of bitwise AND that if x & y = y, then x is a supermask of y. If this condition is true, then a[i] is a supermask of k.
      And &= a[i];: If a[i] is a supermask of k, the code computes the bitwise AND of And and a[i] and stores the result back in And. It's trying to keep track of the bitwise AND of all supermasks of k in the array.
      if(And == k): At the end, if the bitwise AND of all supermasks is k, it means there's a subsequence whose bitwise AND equals k, so it prints "YES". Otherwise, it prints "NO".
      In summary, And = -1; is used to initialize And in such a way that the first bitwise AND operation with it doesn't affect the result. And And &= a[i]; is used to compute the bitwise AND of all supermasks of k.
      I think after reading this you will understand