leetcode

Leetcode submissions
git clone git://git.laack.co/leetcode.git
Log | Files | Refs | README

maximum-odd-binary-numberV2.py (469B)


      1 # This is the right way. Kinda wasn't thinking that the last
      2 # bit being a one means the number is odd and that is the only
      3 # way....
      4 
      5 
      6 # 30ms 93.00%
      7 # 16.56MB 75.75%
      8 class Solution:
      9 
     10     def maximumOddBinaryNumber(self, s: str) -> str:
     11         ones = s.count("1")
     12         strReturn = ""
     13         for i in range(ones - 1):
     14             strReturn += "1"
     15         for i in range(len(s) - ones):
     16             strReturn += "0"
     17         strReturn += "1"
     18         return strReturn