Skip to content

Commit d08816f

Browse files
committed
Create time-needed-to-rearrange-a-binary-string.go
1 parent 22ad951 commit d08816f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//https://leetcode.com/problems/time-needed-to-rearrange-a-binary-string/
2+
3+
package leetcode_solutions_golang
4+
5+
import "strings"
6+
7+
func secondsToRemoveOccurrences(s string) int {
8+
total := 0
9+
for {
10+
newStr := strings.Replace(s, "01", "10", -1)
11+
if newStr == s {
12+
return total
13+
}
14+
total++
15+
s = newStr
16+
}
17+
}

0 commit comments

Comments
 (0)