Maximum Odd Binary Number - Leetcode 2864 - Python

  Рет қаралды 5,612

NeetCodeIO

4 ай бұрын

🚀 neetcode.io/ - A better way to prepare for Coding Interviews
🧑‍💼 LinkedIn: www.linkedin.com/in/navdeep-singh-3aaa14161/
🐦 Twitter: neetcode1
⭐ BLIND-75 PLAYLIST: kzbin.info/www/bejne/gX3PiXZ8fJqHpKM
Problem Link: leetcode.com/problems/maximum-odd-binary-number/description/
0:00 - Read the problem
0:27 - Drawing Explanation
2:29 - Coding Explanation
4:36 - Drawing Explanation
7:44 - Coding Explanation
leetcode 2864
#neetcode #leetcode #python

Пікірлер: 17
@junaidmahmud2894
@junaidmahmud2894 4 ай бұрын
Just solved the problem and came to KZbin and Boom! your solution! You're amazing man!
@swauce507
@swauce507 4 ай бұрын
Thanks to you neetcode, after spending my entire 4th year grinding leetcode I recieved my 1st fulltime swe offer after I graduate!!! Thank you for all you do!
@unknownbirdpro
@unknownbirdpro 4 ай бұрын
How many problems did you solve till now?
@shreehari2589
@shreehari2589 4 ай бұрын
Which company?
@dingus2332
@dingus2332 4 ай бұрын
Solved with First Intuition , but have always in store for us to learn !
@metarus208
@metarus208 4 ай бұрын
thanks Navdeep
@OverrideTips
@OverrideTips 4 ай бұрын
As always I’m here!🙏🏼🙏🏼 fire video, still waiting for the military discount 😂
@suryarajendran7736
@suryarajendran7736 4 ай бұрын
It will be really helpful if you could share an excel just like how you did for blind75 for the neetcode150 problems too. Thanks in advance!!!
@Andrew_J123
@Andrew_J123 4 ай бұрын
Bit of a pythonic solution but it's neat imo. class Solution: def maximumOddBinaryNumber(self, s: str) -> str: ones = s.count("1") zeros = s.count("0") return (ones-1)*'1' + zeros*'0' + '1'
@jeehar1
@jeehar1 4 ай бұрын
you don't need to count zeros, zeros = len(s)-ones. A more pythonic way would be : def maximumOddBinaryNumber(self, s: str) -> str: return '1' * ((ones:=s.count('1')) - 1) + '0' * (len(s)-ones) + '1'
@Andrew_J123
@Andrew_J123 4 ай бұрын
@@jeehar1 I agree you don't have to count zeros but imo I still kinda like mine as I see it as a bit more readable although I appreciate you using the walrus operator (At least that's what I think := is called)
@1vader
@1vader 4 ай бұрын
@@jeehar1Inlining the variable is super unreadable, definitely not more pythonic.
@leeroymlg4692
@leeroymlg4692 4 ай бұрын
@@jeehar1 worse readability
@Doggy_Styles_Coding
@Doggy_Styles_Coding 4 ай бұрын
nice one
@anirbanhossen6170
@anirbanhossen6170 4 ай бұрын
@NeetCodeIO Minimum Operations to Exceed Threshold Value II solve this without using queue ged rid of the Time Limit Exceeded 671 / 675 testcases passed(my solution)using sorting
@LlamaBG
@LlamaBG 4 ай бұрын
WHERE IS THE VIDEO MAN
Вечный ДВИГАТЕЛЬ!⚙️ #shorts
00:27
Гараж 54
Рет қаралды 14 МЛН
你们会选择哪一辆呢#short #angel #clown
00:20
Super Beauty team
Рет қаралды 19 МЛН
Heartwarming: Stranger Saves Puppy from Hot Car #shorts
00:22
Fabiosa Best Lifehacks
Рет қаралды 20 МЛН
Мы никогда не были так напуганы!
00:15
Аришнев
Рет қаралды 6 МЛН
Вечный ДВИГАТЕЛЬ!⚙️ #shorts
00:27
Гараж 54
Рет қаралды 14 МЛН