Copy Set Bits in a Range | Toggle Bits in a Range | Bit Manipulation Interview Questions
Vložit
- čas přidán 6. 09. 2020
- Please consume this content on nados.pepcoding.com for a richer experience. It is necessary to solve the questions while watching videos, nados.pepcoding.com enables that.
NADOS also enables doubt support, career opportunities and contests besides free of charge content for learning. In this video, we discuss the Copy Set Bits in a Range problem using bit manipulation algorithms. In this problem,
1. You are given two numbers A and B.
2. You are given two more numbers left and right, representing a range [left,right].
3. You have to set bits in B which are set in A lying in the above mentioned range.
4. Print the updated number B.
To submit the question, click here: www.pepcoding.com/resources/d...
For a better experience and more exercises, VISIT: www.pepcoding.com/resources/o...
#bitmanipulation #bits
Have a look at our result: www.pepcoding.com/placements
Follow us on our FB page: / pepcoding
Follow us on Instagram: / pepcoding
Follow us on LinkedIn: / pepcoding-education
I don't understand why the likes and views on your channel are low. You deserve more. The way you teach is exceptional and needs a lot of appreciation and attention.
My reaction at 7:32 is like wow. i mean i know this thing right, i know this pattern, i have observed that, bit i never thought it will come handy in this way. Thanks man! Great work!
You deserve much more views than this! Great Explaination man!!
Thankyou beta,
I am glad you liked it. I also hope that you are watching till end.
If you like our efforts, will you like to write a few words about us here (www.quora.com/How-do-I-start-learning-or-strengthen-my-knowledge-of-data-structures-and-algorithms )
Next Level ;) sumeet sir please More videos on LeetCode hard problems on DP , Bitmask, Graph etc.
Simple and Amazing explanation!
Thank you so much sir your effort is priceless i watch your all videos thankyou so much it s very helpfull for me 🥰
simple and wonderful explanation
AND All my doubts are solved by watching this! Thank you so much sir!
Thankyou beta!
I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem.
If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
utter perfection!
very good explanation for finding the mask, gfg was very confusing, thanks
Awesome expression👌👌🔥
Thanks
thanks
Thank you!
You're welcome! and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
Thanku soo much sir for all these contents😀
If you like our efforts, we request a review
g.page/Pepcoding/review?rc
You can subscribe to our channel here
czcams.com/users/Pepcodingabout?view_as=subscriber
For clearing your doubts, you can join our community on telegram
t.me/pepcoding
No coding Platform is gonna beat you in future.
1. Wrote reviews on quora
2. subscribed
3. If i find a question is explained by Pepcoding on youtube, i can't even think of going to another channel.
🙏🙏🙏
You guys are killing it
Thank you so much. Keep learning, Keep growing and keep loving Pepcoding!😊
completely agreed man
thank u so much...
You are welcome!
you should be a professor in IIT...great job bro
Glad to know that you liked the content and thank you for appreciating.
The love and respect which I get from you people keep me highly motivated and the same I am able to forward It to you people through my videos.
So, keep motivating, keep learning and keep loving Pepcoding😊
@@Pepcoding Sir video ke end mai Time complexity bhi ek baar jaldi se discuss kardiya kare code ki👍👍
Video poori achhe se samjh aa gayi , agle ek saal tak nahi bhulunga
Very Nice Explanation.....Keep making videos
Thank you, I will
Guys this logic will fail if right is greater than number of bits in binary representation of A , so to handle that make right as minimum of (right,length of binary string of A ) which can be done as follows :
right = Math.min(right,len(A)); // call to len function
len function code :
static int len(int num){
int len = ((int)(Math.log(num)/Math.log(2))) +1;
return len;
}
+1 to this.
This should be a pinned comment.
Amazing content!
Thankyou beta!
I am glad you liked it. I also hope that you are watching till end and trying to understand the what, how and especially why of the problem.
If you like our efforts, we request a review - g.page/Pepcoding/review?rc
@@Pepcoding Absolutely sir. I understood the concept really well and was able to code it on my own as well.
Thank you!
Nice explanation sir
Keep learning.
And for better experience and well organised content visit nados.pepcoding.com
Awesome explanation 😀😀
Seekhte rahie. Bhot khushi ho rahi hai ki aap sare questions dekh rhe hain
@@Pepcoding sir content is really good l. I never get bored while watching videos
sir use 1l literal it will help and it will be more efficient for a larger problem
simple approach
for (int i=left-1; i
sir ap toh bade aggresively padha rhe but explaination was good
time complexity would be o(1) na??
Beta, I regret to inform you that, I won't be able to answer/solve the personal doubts of each and every student over here. For clearing your doubts, you can join our community on telegram - t.me/pepcoding.
yes it's O(1)
agr sir isme esa case aaya ki carry aa rha ho toh yeh algo fail ho jaega na?
Beta, I regret to inform you that, I won't be able to answer/solve the personal doubts of each and every student over here. For clearing your doubts, you can join our community on telegram - t.me/pepcoding.
sr approach to same hi sochi thi bs mask code ni hua khud se
shabaash!!
@@Pepcoding sr aap almost sbhi comments ka reply krte ho aisa lgra hai ekdm offline pdhra hu
anyone submitting on gfg take 1ll instead of 1
can use the code
if(x == y) return x;
if(l 32) return x;
int mask = 1ll
SAARA TEST CASE PASS HUYA THA?
Easy tha kaafi phir b na ho paya
Beta, agr questions banne lge to ghamand nh krna aur agr naa ho to haar nh maan ni.
Aur aise h apna pyaar bnaye rkhe aur pdte rhe😊
@@Pepcoding great thoughts sir... learnt a lot😊