bhaiya bohot achha explaination tha. Please keep continue these type of question. Xor bitwise waale questions samjh nhi aate. Please suggest some material
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.
@@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.
@@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
Great work thanks alot bhaiya app itni easily explain kar dete hai tough question bi
Thanks 🌹
From where you have learn about SuperMask property ???
tnx bro for this new trick.
Its Damn easy !!
Thankyou So much !!
From where you have learn about SuperMask property ???
Geeks for geeks Bitmasking or you can also search bit tricks for cp😁
bhaiya bohot achha explaination tha. Please keep continue these type of question. Xor bitwise waale questions samjh nhi aate. Please suggest some material
bro your explaination is just fabulous have no words ......☺☺☺
So nice of you
What's the binary value for -1(negative 1)
@@thumatibhavani9375 1111111111111111
Can you pls post other question solutions also
bro subsequence too 1 size ka bhi ho sakta ha too jab ek element mil gaya fhir kyu check krna
❤❤
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?
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.
@@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.
do it in english bro
suscriber++;
Bro please explain in english too
You do not know hindi?
Yes I don't know I am from telugu state..can you tell me the binary value for -1
@@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