Рет қаралды 2,836
Whatsapp Community Link : www.whatsapp.com/channel/0029...
This is the 21st Video of our Playlist "Leetcode Easy".
We will be solving "Power of Two | Multiple Approaches | Leetcode 231" using multiple approaches.
Problem Name : Power of Two | Leetcode 231
Company Tags : GOOGLE, ADOBE
My solutions on Github : github.com/MAZHARMIK/Intervie...
Leetcode Link : leetcode.com/problems/power-o...
Approach Summary :
Approach-1 (Using normal division):
Time Complexity (T.C): O(log(n))
Space Complexity (S.C): O(1)
Recursively checks if the given number is a power of two by repeatedly dividing it by 2 until it reaches 1.
Approach-2 (Using bit magic):
Time Complexity (T.C): O(1)
Space Complexity (S.C): O(1)
Utilizes bitwise operations to efficiently check if the given number is a power of two. It ensures that only one bit is set in the binary representation.
Approach-3 (__builtin_popcount):
Time Complexity (T.C): O(1)
Space Complexity (S.C): O(1)
Takes advantage of the Integer.bitCount method in Java, which counts the number of set bits (1s) in the binary representation. It checks if exactly one bit is set, indicating a power of two.
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 - Problem Explanation
01:30 - Approach-1 (simple division)
03:10 - Approach-2 (Bit Magic)
05:38 - Approach-3 (Using built-in function)
08:18 - Approach-4 (Bhai Bhai Bhai Approach)
#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