Power of Four | 3 Approaches | Maths | With Proof | Bit Magic | Leetcode - 342

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

codestorywithMIK

codestorywithMIK

9 ай бұрын

Whatsapp Community Link : www.whatsapp.com/channel/0029...
PRF Notes - github.com/MAZHARMIK/Intervie...
This is the 14th Video of our Maths Playlist.
In this video we will try to solve a very good Greedy Problem - Power of Four (Leetcode-342).
I will explain each line of code. You must know the "WHY" behind everything.
Also there are 3 approaches in this video.
I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases.
Problem Name : Power of Four
Company Tags : Two Sigma
My solutions on Github : github.com/MAZHARMIK/Intervie...
Leetcode Link : leetcode.com/problems/power-o...
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
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
#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

Пікірлер: 43
@kakaji6470
@kakaji6470 9 ай бұрын
Such a good explanation dude...Every Concept clear like water...Dude just one request can you pls also attach the note where you write all the stuff in the video !
@codestorywithMIK
@codestorywithMIK 9 ай бұрын
Thank you so much. Sure thing. Actually i have not started to attach the PDFs in my Github repo also - github.com/MAZHARMIK/Interview_DS_Algo/tree/master/iPad%20PDF%20Notes You can check the PDFs there 😇🙏
@salverulaxmivivek3438
@salverulaxmivivek3438 7 ай бұрын
wow great
@anuppatankar4294
@anuppatankar4294 9 ай бұрын
Great Video 👌🏻
@ManojKrVerma-vw4dx
@ManojKrVerma-vw4dx 9 ай бұрын
you reminded us our school days.
@codestorywithMIK
@codestorywithMIK 9 ай бұрын
🙏😇
@ProfessorLucifer
@ProfessorLucifer 9 ай бұрын
waiting for your video bro and again u r great
@codestorywithMIK
@codestorywithMIK 9 ай бұрын
Means a lot. Thank you so much 😇🙏
@user-ub2is4rs4x
@user-ub2is4rs4x 9 ай бұрын
You put so much importance on Proofs and making this clear. This is what makes you stand out of the crowd. You are unique 🔥👌🏻
@newglobal2056
@newglobal2056 9 ай бұрын
Ajj itna jaldi video aa aya thankyou bhaiya 3 rd wala approach pura chamka or ha congratulations 🎉🎉🎉🎉🎉 for 11k subs❤❤❤
@codestorywithMIK
@codestorywithMIK 9 ай бұрын
Means a lot. Thank you so much 😇🙏
@lofireverbz-wy7go
@lofireverbz-wy7go 9 ай бұрын
understood all 3 approachess
@codestorywithMIK
@codestorywithMIK 9 ай бұрын
😇🙏
@saurabhKumar-hj6yp
@saurabhKumar-hj6yp 9 ай бұрын
Thank you so much ❤
@codestorywithMIK
@codestorywithMIK 9 ай бұрын
You're welcome 😊
@sayantanbandyopadhyay7803
@sayantanbandyopadhyay7803 9 ай бұрын
congrats for 11k bhaiyaa ❤.
@codestorywithMIK
@codestorywithMIK 9 ай бұрын
Thank you so much 🙏😇
@codinghero2001
@codinghero2001 9 ай бұрын
Thank You !!! Nice explanation
@umeshbisht1054
@umeshbisht1054 9 ай бұрын
Thanku bhaiya ❤ I solved this problem (n&(n-1))==0&& (n-1)%3==0 Then return true; Else False;
@Abhay14
@Abhay14 9 ай бұрын
bhaiya mujhe open source krna h can you guide where i have to start
@shloksuman8164
@shloksuman8164 9 ай бұрын
explained really well!
@Thriftinghai
@Thriftinghai 9 ай бұрын
marvelous explanation . all 3 approaches
@ugcwithaddi
@ugcwithaddi 9 ай бұрын
Thanks for proving mathematical for approach-3 . You genuinely cate for the quality of the video. Thanks a lot for teaching us so much
@aryamansingha9984
@aryamansingha9984 9 ай бұрын
Bahut Easy hain bhaiya -> Brute - Force 1) Simple and Traditional Way bool isPowerOfFour(int n) { // Brute-Force // Step 1 to check the number is greater than 0 or not if(n1) { // STEP 3:- Is it pass then // STEP 4:- it will check the number divvided means it will check for the numbr (odd number ) if(n%4!=0) { // Is not pass return false; } // Again it will reduce the number n/=4; } // IS to check the number is 1 return n==1; }
@KCODivyanshuKatyan
@KCODivyanshuKatyan 9 ай бұрын
goat ❤❤
@devkumar9889
@devkumar9889 9 ай бұрын
Ans => (n>0 && (n & 0x55555555 == n) && (n & (n-1) == 0 )
@AnadiHirpara
@AnadiHirpara 9 ай бұрын
Aapne second approach me stating me if(n
@codestorywithMIK
@codestorywithMIK 9 ай бұрын
Compiler automatically type-castes 0 to False and 1 to True
@AnadiHirpara
@AnadiHirpara 9 ай бұрын
ohk ohk!@@codestorywithMIK
@ravirajshelar250
@ravirajshelar250 9 ай бұрын
For 3rd approach cant we apply the conditions of one set bit and position of that bit in odd position as the criteria? Also there is a formula for a^n - b^n, which can also be used to prove that (4^x -1)%3==0
@codestorywithMIK
@codestorywithMIK 9 ай бұрын
I believe yes. And that’s an amazing observation. Thanks for sharing. Let me explore more on this
@aayush0606
@aayush0606 9 ай бұрын
please start solving leetcode weekly and bi-weekly contest problems too, that will be very helpful
@codestorywithMIK
@codestorywithMIK 9 ай бұрын
I will soon start that. It usually gets difficult sometimes due to my travel and sometimes office plans
@aayush0606
@aayush0606 9 ай бұрын
@@codestorywithMIK take your time, you can simply start with weekly and upload them before start of next contest so you can have time for producing quality content and at the same time your work won't be affected, also keep your own priorities first as we don't want you to drift from your own work and daily videos, hope my suggestion is helpful :-)
@codestorywithMIK
@codestorywithMIK 9 ай бұрын
@aayush82 Thank you for this precious suggestion ❤️❤️❤️
@Ramneet04
@Ramneet04 9 ай бұрын
10&9 is not giving 0 how can we say it is divisible by 2? 1010 1001 Will give 1000 Does it checks the last bit only????
@codestorywithMIK
@codestorywithMIK 9 ай бұрын
n & (n-1) is used to check if n is a Power of 2
@Ramneet04
@Ramneet04 9 ай бұрын
@@codestorywithMIK yes but how 10 &9 is showing that 10 is divisible by 2
@harsh.jain22
@harsh.jain22 9 ай бұрын
@@Ramneet04 if (10 & 9 ) == 0 then only we can say that 10 is a power of 2, but 10&9 = 0100 which is not 0 hence 10 is not a power of 2
@Ramneet04
@Ramneet04 9 ай бұрын
@@harsh.jain22 oh sorry I thought divisible 🙃 we were checking power my bad . Thx a lot
@xiaoshen194
@xiaoshen194 9 ай бұрын
return bitset(n).count==1 and (((int)log2(n))&1)==0; Beats 100% tc and sc.
Poor Pigs | Maths | With Intuition | Clear Explanation | Leetcode - 458
33:07
Power of Two | Multiple Approaches | Leetcode 231
17:16
codestorywithMIK
Рет қаралды 2,8 М.
Самый Молодой Актёр Без Оскара 😂
00:13
Глеб Рандалайнен
Рет қаралды 5 МЛН
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 351 М.
Shaadi aur Election 2024 - Standup Comedy by Varun Grover
10:28
Varun Grover
Рет қаралды 1,5 МЛН
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
The LeetCode Fallacy
6:08
NeetCode
Рет қаралды 448 М.
Crack coding rounds in Big Tech
14:44
Shafiqa Iqbal
Рет қаралды 10 М.