diff --git a/1044-longest-duplicate-substring.go b/1044-longest-duplicate-substring.go index a94a27a..4400b3f 100644 --- a/1044-longest-duplicate-substring.go +++ b/1044-longest-duplicate-substring.go @@ -214,8 +214,9 @@ func LongestDupSubstringSmartforceMark3Goroutine(s string, from int, to int) str return "" } - indicesNext := []int{} - indicesAll := []int{} + indicesNext := make([]int, 0, len(s)) + indicesAll := make([]int, 0, len(s)) + indicesEmpty := make([]int, 0, len(s)) for j := 0; j < strLen; j++ { indicesAll = append(indicesAll, j) @@ -243,7 +244,7 @@ func LongestDupSubstringSmartforceMark3Goroutine(s string, from int, to int) str } indicesCurrent = indicesNext - indicesNext = []int{} + indicesNext = indicesEmpty } }