Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 4bf30dc

Browse files
committed
984 finish
1 parent 5bc6c1c commit 4bf30dc

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

Algorithms/0984.string-without-aaa-or-bbb/string-without-aaa-or-bbb.go

+5-9
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,13 @@ func strWithout3a3b(A int, B int) string {
1212
a, b = b, a
1313
}
1414

15-
aab := []byte{a, a, b}
16-
17-
for A > B && B > 0 {
18-
sb.Write(aab)
19-
A -= 2
20-
B--
21-
}
22-
23-
for A > 0 || B > 0 {
15+
for A > 0 {
2416
sb.WriteByte(a)
2517
A--
18+
if A > B {
19+
sb.WriteByte(a)
20+
A--
21+
}
2622
if B > 0 {
2723
sb.WriteByte(b)
2824
B--

0 commit comments

Comments
 (0)