Bitwise AND of Numbers Range | 2 Approaches | Dry Run | Leetcode 201

preview_player
Показать описание
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

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.

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝

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.❣❣❣

codestorywithMIK
Автор

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!

aadil
Автор

Bahiya bit manipulation pe bhi ek playlist bana do like recursion. 1 video per week is enough. 🙏🙏🙏🙏

manimanohar_
Автор

Very well explained :) One of the better videos than all the other videos I have seen on this question. Thanks

amitchoraria
Автор

Take care of yourself brother the season is changing I was also sick a while ago. And Thank you for the explanation as always!.

aadil
Автор

The way you are being consistent even after being sick gives me so much inspiration to be disciplined and keep going. Thank you.

adityaparab
Автор

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 ;)

arjunprasad
Автор

Hats off to your dedication. and take care get well soon.

wearevacationuncoverers
Автор

I was waiting for you only. Thanks a lot

souravjoshi
Автор

Thanks again for making this easy through your explanation ❤❤

Ankitkumar-fzkc
Автор

I have tried from side.
Then, I was waiting for your video for better understanding

sapnokasahar
Автор

Hore krishna. bhai you are just amazing. nice explanation. learned many things from this video.

JoyAcharyatvl
Автор

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

saketyadav
Автор

2nd solution is quite nice but i dont think i will ever come up with that in an interview 😅

uvs_
Автор

Thanks a lot bhaiya ❤❤ Hats of to your dedication making videos even when you are not well 🫡Get well soon 🙌

gauravbanerjee
Автор

as usual sir you are amazing and your explanation is fabulous you never ever disappoint us

viditvaish
Автор

Recursion best use by your guidance.
class Tree{
public void serialize (Node root, ArrayList<Integer >A){
if(root==null){
A.add(-1);
return;
}
A.add(root.data);
serialize(root.left, A);
serialize(root.right, A);
}
public Node deSerialize(ArrayList<Integer >A){
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;
}
}
🎉❤

dayashankarlakhotia
Автор

Bhaiya pehle app lld Lao please and upp jaldi thik ho jao❤❤

newglobal
Автор

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

EatCodeAndSleep
Автор

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

vikassingh