Bitwise AND of Numbers Range | 2 Approaches | Dry Run | Leetcode 201
Vložit
- čas přidán 28. 07. 2024
- Whatsapp Community Link : www.whatsapp.com/channel/0029...
This is the 11th Video of our Playlist "Bit-Manipulation : Popular Interview Problems".
We will be solving "Bitwise AND of Numbers Range | Leetcode 201" using two approaches.
Problem Name : Bitwise AND of Numbers Range | Leetcode 201
Company Tags : GOOGLE
My solutions on Github : github.com/MAZHARMIK/Intervie...
Leetcode Link : leetcode.com/problems/bitwise...
Approach Summary :
Approach-1 (Using Shift):
Time Complexity (T.C): O(log(n)), where n is the maximum number of bits needed to represent the given input integers left and right.
Space Complexity (S.C): O(1)
Summary: This approach iteratively right-shifts both left and right until they become equal, counting the number of shifts. The result is obtained by left-shifting left by the count of shifts.
Approach-2 (Using AND Property):
Time Complexity (T.C): O(log(n)), where n is the maximum number of bits needed to represent the given input integers left and right.
Space Complexity (S.C): O(1)
Summary: This approach iteratively applies the bitwise AND operation on right and (right - 1) until right becomes less than or equal to left. The result is the value of right after the loop.
Both approaches aim to find the bitwise AND of a range of integers (left to right), with the first approach using a shift-based method and the second approach utilizing the property that bitwise AND between a number and its predecessor resets the rightmost set bit.
My Recursion Concepts Playlist : • Introduction | Recursi...
My DP Concepts Playlist : • Roadmap for DP | How t...
My Graph Concepts Playlist : • Graph Concepts & Qns -...
My GitHub Repo for interview preparation : github.com/MAZHARMIK/Intervie...
Subscribe to my channel : / @codestorywithmik
Instagram : / codestorywithmik
Facebook : / 100090524295846
Twitter : / cswithmik
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
Timelines : ⏰
00:00 - Introduction
00:51 - Problem Explanation
03:17 - Approach-1 Intuition
16:52 - Coding Approach-1 + Time & Space Complexity
20:12 - Approach-2 Intuition
33:33 - Coding Approach-2 + Time & Space Complexity
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #2024 #newyear
Hi guys,
I have not been well since yesterday evening. High fever and throat issue.
Hence the video was delayed.
I hope it helps.
Thank you all for your love and support.❣❣❣
Thank you for such an Insane Consistency, You're Amazing 🙏
larry page real id se aao
Take care MIK
take care you health
Take care bhaiya :)
Bahiya bit manipulation pe bhi ek playlist bana do like recursion. 1 video per week is enough. 🙏🙏🙏🙏
Bhai pehli 7-8 min me hi samaj me aa gaya solution kya mast batate ho aap! mene khud hi solve karliya pura video dekehe bina. bot simple solution tha! Thank you!
Very well explained :) One of the better videos than all the other videos I have seen on this question. Thanks
Take care of yourself brother the season is changing I was also sick a while ago. And Thank you for the explanation as always!.
2nd approach was awesome 👍🏻
I was waiting for you only. Thanks a lot
Thank you sir 😊
Thanks for your explaination!! I tried explaining the first approach to myself by looking at other solutions but was unable to. Was waiting since since morning for your explainer. Wishing you a speedy recovery ;)
Hats off to your dedication. and take care get well soon.
Thanku bhaiya ❤
The way you are being consistent even after being sick gives me so much inspiration to be disciplined and keep going. Thank you.
finallyy 🥳. thanks a lot
Nicely explained bhai❤
Thanks ❤❤❤❤
2nd solution is quite nice but i dont think i will ever come up with that in an interview 😅
Thanks, waiting for bits series
Best explanation, Keep it up❤
Hore krishna. bhai you are just amazing. nice explanation. learned many things from this video.
I bow to u for teaching us new things every single day
U are biggest inspiration to become a great coder ✨✨
Thanks from the bottom of my 💓💓
POTD DONE [21.2.24]✅✅
Get well soon ❤
Waiting for your video bro
Thanks a lot bhaiya ❤❤ Hats of to your dedication making videos even when you are not well 🫡Get well soon 🙌
as usual sir you are amazing and your explanation is fabulous you never ever disappoint us
Why is always that my doubts are literally always cleared when I see your explanation. 😅
in first approach time complexity is o(1) beacause maximum bit in a integer is 32 any number we shift 32 times it becomes zero
Get well soon!
Thanks again for making this easy through your explanation ❤❤
😇❤️
in first approach we r actually right shifting 32 bits at worst case right then tc will be o(32) only right we can call it as O(1) only instead
Perfect 👌
I have tried from side.
Then, I was waiting for your video for better understanding
hahaha i was waiting for this video from you, tho i already watched aryan mittal's video but i really like how you explain stuff so here again
Same. I watched Neetcode, Techdose and Aryan's video. couldn't completely get my doubts cleared. Then I always come to this channel and like always I could get the intuition during half of the video and coded it . Something is unique about him.
Bhaiyaaa please bit manipulation ki playlist bana dijiya like recursion
your playlist is is verry useful
❤❤❤
Thanks, Mik for your hard work, please bring BIT Manipulation Playlist first
please share questions of similar pattern!!
Bhaiya pehle app lld Lao please and upp jaldi thik ho jao❤❤
LCP approach 👌
LCP ?
Please include backtracking and trees concepts and questions
we want Bit Manipulation Playlist!!!
Bhaiya aap kon si company me ho ?
What is the TC of approach 2?
Bro can you tell me the name of application on which you use to explain the problems??
Yes mik thanks a lot for system design , lld, oops
bhaiya please make video on 289 Game of Life and 1499 Max Value of equation
cout
In your dp series ,the climbing stairs and first house robber one is showing only of 6 second..please fix the issue
Check the description of those 6 second videos. It contains the link to the full video in a different playlist. I completed few days ago.
thanks@@ugcwithaddi
did u solved this problem first time ??
Recursion best use by your guidance.
class Tree{
public void serialize (Node root,ArrayListA){
if(root==null){
A.add(-1);
return;
}
A.add(root.data);
serialize(root.left,A);
serialize(root.right,A);
}
public Node deSerialize(ArrayListA){
if(A.size()==0) return null;
int a=A.remove(0);
if(a==-1) return null;
Node root=new Node(a);
root.left =deSerialize(A);
root.right=deSerialize(A);
return root;
}
}
🎉❤