Skip to content

Commit db5e768

Browse files
committed
1096 done
1 parent df67487 commit db5e768

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Algorithms/1096.brace-expansion-ii/brace-expansion-ii.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ func isLetter(r byte) bool {
3636
return 'a' <= r && r <= 'z'
3737
}
3838

39-
// split exp with symbol out of brace
39+
// split exp with symbol NOT in braces
40+
// because braces change priority
4041
func split(exp string, symbol byte) []string {
4142
exp = removeOuterBrace(exp)
4243
count := 0
43-
isOutOfBrace := func() bool {
44-
return count == 0
44+
isInBraces := func() bool {
45+
return count > 0
4546
}
4647
bytes := []byte(exp)
4748
for i, b := range bytes {
@@ -51,7 +52,7 @@ func split(exp string, symbol byte) []string {
5152
case '}':
5253
count--
5354
case symbol:
54-
if isOutOfBrace() {
55+
if !isInBraces() {
5556
bytes[i] = '@'
5657
}
5758
}

0 commit comments

Comments
 (0)