Maximum Odd Binary Number - Leetcode 2864 - Python

Sdílet
Vložit
  • čas přidán 24. 07. 2024
  • 🚀 neetcode.io/ - A better way to prepare for Coding Interviews
    🧑‍💼 LinkedIn: / navdeep-singh-3aaa14161
    🐦 Twitter: / neetcode1
    ⭐ BLIND-75 PLAYLIST: • Two Sum - Leetcode 1 -...
    Problem Link: leetcode.com/problems/maximum...
    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

Komentáře • 17

  • @junaidmahmud2894
    @junaidmahmud2894 Před 4 měsíci +6

    Just solved the problem and came to CZcams and Boom! your solution!
    You're amazing man!

  • @swauce507
    @swauce507 Před 4 měsíci +2

    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!

  • @dingus2332
    @dingus2332 Před 4 měsíci +1

    Solved with First Intuition , but have always in store for us to learn !

  • @metarus208
    @metarus208 Před 4 měsíci

    thanks Navdeep

  • @OverrideTips
    @OverrideTips Před 4 měsíci +1

    As always I’m here!🙏🏼🙏🏼 fire video, still waiting for the military discount 😂

  • @suryarajendran7736
    @suryarajendran7736 Před 4 měsíci

    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!!!

  • @Doggy_Styles_Coding
    @Doggy_Styles_Coding Před 4 měsíci

    nice one

  • @LlamaBG
    @LlamaBG Před 4 měsíci +1

    WHERE IS THE VIDEO MAN

  • @Andrew_J123
    @Andrew_J123 Před 4 měsíci +1

    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 Před 4 měsíci +2

      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 Před 4 měsíci +2

      @@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 Před 4 měsíci +1

      @@jeehar1Inlining the variable is super unreadable, definitely not more pythonic.

    • @leeroymlg4692
      @leeroymlg4692 Před 4 měsíci

      @@jeehar1 worse readability

  • @anirbanhossen6170
    @anirbanhossen6170 Před 4 měsíci

    @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