Skip to content

Commit 4b8f753

Browse files
committed
Time: 38 ms (59.91%), Space: 16.6 MB (45.47%) - LeetHub
1 parent 166295f commit 4b8f753

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

2864-maximum-odd-binary-number/2864-maximum-odd-binary-number.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from collections import Counter
2-
3-
1+
# time complexity: O(n)
2+
# space complexity: O(n)
43
class Solution:
54
def maximumOddBinaryNumber(self, s: str) -> str:
6-
return '1' * (s.count('1') - 1) + '0' * (len(s) - s.count('1')) + '1'
5+
oneFreq = s.count('1')
6+
return '1' * (oneFreq - 1) + '0' * (len(s) - oneFreq) + '1'
77

88

99
s = "010"

0 commit comments

Comments
 (0)