Power of Four | LeetCode 342 | C++, Java, Python

  Рет қаралды 11,377

Knowledge Center

Knowledge Center

4 жыл бұрын

LeetCode Solutions: • LeetCode Solutions | L...
August LeetCoding Challenge: • Playlist
Github Link: github.com/KnowledgeCenterYou...
*** Best Books For Data Structures & Algorithms for Interviews:*********
1. Cracking the Coding Interview: amzn.to/2WeO3eO
2. Cracking the Coding Interview Paperback: amzn.to/3aSSe3Q
3. Coding Interview Questions - Narasimha Karumanchi: amzn.to/3cYqjkV
4. Data Structures and Algorithms Made Easy - N. Karumanchi: amzn.to/2U8FrDt
5. Data Structures & Algorithms made Easy in Java - N. Karumanchi: amzn.to/2U0qZgY
6. Introduction to Algorithms - CLR - Cormen, Leiserson, Rivest: amzn.to/2Wdp8rZ
*****************************************************************************
August LeetCoding Challenge | Problem 4 | Power of Four | 4 August,
Facebook Coding Interview question,
google coding interview question,
leetcode,
Power of Four,
Power of Four c++,
Power of Four Java,
Power of Four python,
Power of Four solution,
342. Power of Four,
#CodingInterview #LeetCode #AugustCodingChallenge #Google #Amazon #bitmanipulation #PowerOfFour

Пікірлер: 44
@crisag.2698
@crisag.2698 4 жыл бұрын
Amazing, I've learned so much from you. Thank you so much for all of your content.
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Happy to hear that!
@acxd
@acxd 4 жыл бұрын
Improved audio quality , presentation and explanation method. This man is on a roll. Keep Making !
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Thanks a ton
@raviashwin1157
@raviashwin1157 4 жыл бұрын
Wake up at morning...watch knowledge center daily leetcode challenge videos..do extra questions on leetcode...go to sleep
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Good one
@singhrav
@singhrav 4 жыл бұрын
Very nicely explained!! Thank you so much.
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Glad it was helpful!
@mohitarora8985
@mohitarora8985 4 жыл бұрын
use log function class Solution: def isPowerOfFour(self, num): import math if num>0: a=math.log(num)/math.log(4) b=a-int(a) else: return False if b==0: return True
@praveenj3112
@praveenj3112 4 жыл бұрын
Thank you so much
@codestorywithMIK
@codestorywithMIK 4 жыл бұрын
You are too good..
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Many many thanks
@jacksonwahl1496
@jacksonwahl1496 4 жыл бұрын
very helpful! thank you for the great explanation
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Glad it was helpful!
@codenchill5636
@codenchill5636 4 жыл бұрын
Beautifully explained sir!!!!
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Thanks.
@nopecharon
@nopecharon Жыл бұрын
Awesome explanation
@KnowledgeCenter
@KnowledgeCenter Жыл бұрын
Thanks.
@mohammadyahya78
@mohammadyahya78 2 жыл бұрын
Thank you. None has reached your level at explaining leetcode so far.
@KnowledgeCenter
@KnowledgeCenter 2 жыл бұрын
Glad to hear that!
@akshatmathur278
@akshatmathur278 Жыл бұрын
Thanks for this video. Great explanation.
@KnowledgeCenter
@KnowledgeCenter Жыл бұрын
Glad it was helpful!
@shyamprakashm6325
@shyamprakashm6325 4 жыл бұрын
Thanks you sir nice
@Starfalll6783
@Starfalll6783 4 жыл бұрын
Please add #bitmanipulation so that searching all bit manipulation videos will be easy
@manu-singh
@manu-singh 4 жыл бұрын
Bro where should I focus on codeforces or codechef
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
If your goal is cracking interviews, focus on Leetcode. If you enjoy competitive programming, go with Codeforces/Codechef.
@shivanktripathi4661
@shivanktripathi4661 4 жыл бұрын
can we take log (base 4) in c++....if yes then how
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Use this formula. log_a(b) = log_c(b)/log_c(a) => log base a of b = (log base c of b)/(log base c of a) => log_4 (x) = log(x)/log(4) Hence, this is the formula you are looking for.
@shivanktripathi4661
@shivanktripathi4661 4 жыл бұрын
@@KnowledgeCenter thanks
@RishiRaj-dl1mg
@RishiRaj-dl1mg 4 жыл бұрын
log4(number) . This will work
@midhileshmomidi2434
@midhileshmomidi2434 4 жыл бұрын
try: return int(math.log(num,4)) == (math.log(num,4)) except ValueError: pass
@pillabindu6661
@pillabindu6661 4 жыл бұрын
what is "x" in 0xaaaaaaaa dont mind im yet a beginner hoping for clarification of this doubt
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Hexadecimal numbers are preceded by 0x.
@pillabindu6661
@pillabindu6661 4 жыл бұрын
@@KnowledgeCenter thanks for the answer
@only_for_fun1234r
@only_for_fun1234r Жыл бұрын
I too had a doubt here , how it become 01010101010101??
@rishisharma5249
@rishisharma5249 4 жыл бұрын
My Solution Time- O(1), Space- O(1) bool isPowerOfFour(int num) { if(num
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Correct.
@rishisharma5249
@rishisharma5249 4 жыл бұрын
@@KnowledgeCenter Enjoying your videos Sir, keep going!!!
@deepakkumarsahu4340
@deepakkumarsahu4340 4 жыл бұрын
class Solution { public: bool isPowerOfFour(int num1) { if(num1 == 1) return true; long long int num = num1; if((num & num - 1) == 0 && (num % 10 == 4 || num%10 == 6 )) return true; return false; } }; Explanation: each power of 4 has either 4 or 6 one's digit. And power(4) is a subset of power(2) and we can solve power(2) as (n & n-1) == 0 and check whether it has units digit 4 and 6
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Good.
@deepakkumarsahu4340
@deepakkumarsahu4340 4 жыл бұрын
Thanks ... ur videos are really helpful
@JardaniJovonovich192
@JardaniJovonovich192 4 жыл бұрын
return (num>0 && (num & (num-1)) == 0 && (int)log2(num) % 2 == 0);
@kenjiasuka3842
@kenjiasuka3842 4 жыл бұрын
return (num & (num-1) == 0) && (num & 0x55555554 != 0); // for 32-bit int
@kenjiasuka3842
@kenjiasuka3842 4 жыл бұрын
return (num & (num-1) == 0) && (num & 0x5555555555555554 != 0); // for 64-bit int
Non-overlapping Intervals | LeetCode 435 | C++, Java, Python
20:35
Knowledge Center
Рет қаралды 7 М.
Mom's Unique Approach to Teaching Kids Hygiene #shorts
00:16
Fabiosa Stories
Рет қаралды 10 МЛН
Scary Teacher 3D Nick Troll Squid Game in Brush Teeth White or Black Challenge #shorts
00:47
That's how money comes into our family
00:14
Mamasoboliha
Рет қаралды 12 МЛН
路飞被小孩吓到了#海贼王#路飞
00:41
路飞与唐舞桐
Рет қаралды 76 МЛН
Implement Rand10() Using Rand7() | LeetCode 470 | C++, Java, Python
10:43
The Algorithm Behind Spell Checkers
13:02
b001
Рет қаралды 408 М.
Find All Duplicates in an Array | LeetCode 442 | C++, Java, Python
11:23
Knowledge Center
Рет қаралды 44 М.
Sum of Left Leaves | LeetCode 404 | C++, Java, Python
10:38
Knowledge Center
Рет қаралды 11 М.
Top 6 Coding Interview Concepts (Data Structures & Algorithms)
10:51
Google Coding Interview With A Competitive Programmer
54:17
Clément Mihailescu
Рет қаралды 2,5 МЛН
Intro to Competitive Programming
11:41
Junferno
Рет қаралды 766 М.
Best Time to Buy and Sell Stock iii | LeetCode 123 | C++, Java, Python
20:16
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 155 М.
Mom's Unique Approach to Teaching Kids Hygiene #shorts
00:16
Fabiosa Stories
Рет қаралды 10 МЛН