func maximumBinaryString(binary string) string { n := len(binary) first := 0 for first < n { if binary[first] != '1' { break } first++ } if first >= n { return binary } oneCount := 0 for i := first; i < n; i++ { if binary[i] == '1' { oneCount++ } } return strings.Repeat("1", n-oneCount-1) + "0" + strings.Repeat("1", oneCount) }