728x90
https://leetcode.com/problems/maximum-odd-binary-number
class Solution:
def maximumOddBinaryNumber(self, s: str) -> str:
count = [0, 0]
count[0] = s.count('0')
count[1] = s.count('1')
s = ''
for i in range(count[1] - 1):
s += '1'
for i in range(count[0]):
s += '0'
s += '1'
return s
728x90
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 2540. Minimum Common Value (0) | 2024.03.09 |
---|---|
[Leetcode] 3005. Count Elements With Maximum Frequency (1) | 2024.03.08 |
[Leetcode] 876. Middle of the Linked List (0) | 2024.03.07 |
[Leetcode] 961. N-Repeated Element in Size 2N Array (0) | 2024.03.07 |
[Leetcode] 2670. Find the Distinct Difference Array (0) | 2024.03.07 |