Bitwise AND of Numbers Range | 2 Approaches | Dry Run | Leetcode 201
Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
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 : https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Bit_Magic/Bitwise%20AND%20of%20Numbers%20Range.cpp
Leetcode Link : https://leetcode.com/problems/bitwise-and-of-numbers-range/
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 : https://www.youtube.com/watch?v=pfb1Zduesi8&list=PLpIkg8OmuX-IBcXsfITH5ql0Lqci1MYPM
My DP Concepts Playlist : https://youtu.be/7eLMOE1jnls
My Graph Concepts Playlist : https://youtu.be/5JGiZnr6B5w
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Interview_DS_Algo
Subscribe to my channel : https://www.youtube.com/@codestorywithMIK
Instagram : https://www.instagram.com/codestorywithmik/
Facebook : https://www.facebook.com/people/codestorywithmik/100090524295846/
Twitter : https://twitter.com/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