Power of Two | Multiple Approaches | Leetcode 231

  Рет қаралды 2,836

codestorywithMIK

codestorywithMIK

Күн бұрын

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

Пікірлер: 29
@newglobal2056
@newglobal2056 5 ай бұрын
8:43 ye sahi tha😂😂😂😂❤❤❤❤❤❤❤
@lofireverbz-wy7go
@lofireverbz-wy7go 5 ай бұрын
BHAI BHAI approach: candidate rocked interviewer shocked ❣❣thanks bhaiya for awesome explaination
@shreyash_17_
@shreyash_17_ 5 ай бұрын
done with revision of leetcode easy playlist . now starting with 2 pointers playlist and bhaiya i was able to do all questions on own . thanks bhaiya u r explanation & approaches are awesome mind blowing .
@gauravbanerjee2898
@gauravbanerjee2898 5 ай бұрын
Thanks a lot bhaiya ❤, last approach dekh k maza agya 🤣🔥
@HI-wl9el
@HI-wl9el 5 ай бұрын
Another approach Using log2 func in cpp return ceil(log2(n)) == floor (log2(n))
@subhajitdey135
@subhajitdey135 5 ай бұрын
Bit manipulation is mostly observation based patterns 😸
@oqant0424
@oqant0424 5 ай бұрын
POTD DONE [19.2.24]✅✅ solved on myself using loop thanks for the rest 3 approaches ✨✨
@ishwarreddy8820
@ishwarreddy8820 5 ай бұрын
could you plz take up codeforces contest questions also
@harjotanand834
@harjotanand834 5 ай бұрын
Thanks sir for the no of approaches ..... But sir , i was trying an approach in which i used log func like , in mathematical form if 2^x = n , then log (2^x) = log n and so x = logN/log2 But this approach gave wrong ans in 1087 testcase , can you pls tell where this gone wrong ???
@KishanSingh-vc3re
@KishanSingh-vc3re 5 ай бұрын
Bhaiya though I am able to solve some questions, the problems especially the last one in contests is never done for me, please make a videos on them too, it's easy for you and help people like me
@anjanasahay2172
@anjanasahay2172 5 ай бұрын
OOPS Too Sir 🙏🙏❤️❤️
@rashidmazhar023
@rashidmazhar023 5 ай бұрын
Please make a video on "3040. Maximum Number of Operations With the Same Score II" which was asked in leetcode contest 124
@divsworld5925
@divsworld5925 5 ай бұрын
bhai bhai bhai approach bhaiya😂😂😂
@codeandtalk6
@codeandtalk6 5 ай бұрын
❤❤❤❤❤
@manimanohar_001
@manimanohar_001 5 ай бұрын
Bhaiya bit manipulation pe bhi playlist bana do pls
@souravjoshi2293
@souravjoshi2293 5 ай бұрын
Approach-4, Interviewer be like "Abe Saale" 🤣🤣🤣🤣
@tutuimam3381
@tutuimam3381 5 ай бұрын
❤❤❤❤
@awkward_adi
@awkward_adi 5 ай бұрын
Can you please make a tutorial on weekly contest 385 4th question
@idiomz4104
@idiomz4104 5 ай бұрын
in approach 2, what is the guarantee that other numbers dont exhibit the same behaviour? How do we know for sure that if we subtract 1 and then & with the original number, we wont end up with 0 for non-powers of 2?
@nitishraj7274
@nitishraj7274 5 ай бұрын
Try taking any number not power of 2 you won't get 0
@idiomz4104
@idiomz4104 5 ай бұрын
@@nitishraj7274 I agree but that's not a mathematical proof, that's just good enough to be superficially convinced with the intuition. We can not test for every number out there one by one, so how can we be sure it holds true for all? There must be some kind of logical proof.
@aws_handles
@aws_handles 5 ай бұрын
8:43 😂
@harikrushnasuhagiya3925
@harikrushnasuhagiya3925 5 ай бұрын
Bhai kal ke contest ka 4th Que shikhado
@oqant0424
@oqant0424 5 ай бұрын
last approach😆😂
@amanrajput1530
@amanrajput1530 5 ай бұрын
Bhaiya java me code write kiya karo video me
@AyushKumar-ty4cl
@AyushKumar-ty4cl 5 ай бұрын
Please cover 4th problem of weekly contest.
@FifthArima
@FifthArima 5 ай бұрын
i felt, follow up should have been the actual question.
@codestorywithMIK
@codestorywithMIK 5 ай бұрын
Indeed
@ugcwithaddi
@ugcwithaddi 5 ай бұрын
8:43 😂😂😂
Missing Number | Multiple Approaches | Leetcode 268
24:58
codestorywithMIK
Рет қаралды 3 М.
39kgのガリガリが踊る絵文字ダンス/39kg boney emoji dance#dance #ダンス #にんげんっていいな
00:16
💀Skeleton Ninja🥷【にんげんっていいなチャンネル】
Рет қаралды 7 МЛН
Русалка
01:00
История одного вокалиста
Рет қаралды 7 МЛН
Хотите поиграть в такую?😄
00:16
МЯТНАЯ ФАНТА
Рет қаралды 3,7 МЛН
Power of Two - Leetcode 231 - Python
12:42
NeetCodeIO
Рет қаралды 14 М.
Power of 2 | Leetcode #231 | 4 methods explained
10:17
Techdose
Рет қаралды 38 М.
Count Elements With Maximum Frequency | One Pass | Two Pass | Leetcode 3005
12:50
LeetCode Problem: 231. Power of Two | Java Solution
8:13
Code for Interview
Рет қаралды 2,1 М.
39kgのガリガリが踊る絵文字ダンス/39kg boney emoji dance#dance #ダンス #にんげんっていいな
00:16
💀Skeleton Ninja🥷【にんげんっていいなチャンネル】
Рет қаралды 7 МЛН