Skip to content

Commit 99bcd36

Browse files
committed
Reformat code
1 parent af4a327 commit 99bcd36

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

longest_substring.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
package main
22

33
import (
4-
"fmt"
5-
"strings"
4+
"fmt"
5+
"strings"
66
)
77

88
func lengthOfLongestSubstring(s string) int {
9-
longest := ""
10-
current := ""
9+
longest := ""
10+
current := ""
1111

12-
for _, v := range s {
12+
for _, v := range s {
1313
vStr := string(v)
1414

1515
// Slower
1616
// split := strings.Split(current, vStr)
17-
// if len(split) > 1 {
18-
// fmt.Printf("\nFound %s, Resetting %s to: %s", vStr, current, split[1])
19-
// current = split[1]
20-
// }
17+
// if len(split) > 1 {
18+
// fmt.Printf("\nFound %s, Resetting %s to: %s", vStr, current, split[1])
19+
// current = split[1]
20+
// }
2121

2222
// Faster
23-
oldIndex := strings.Index(current, vStr)
24-
if oldIndex > -1 {
25-
fmt.Printf("\nFound %s at %d, Resetting %s to: %s", vStr, oldIndex, current, current[oldIndex + 1:])
26-
current = current[(oldIndex + 1):]
27-
}
23+
oldIndex := strings.Index(current, vStr)
24+
if oldIndex > -1 {
25+
fmt.Printf("\nFound %s at %d, Resetting %s to: %s", vStr, oldIndex, current, current[oldIndex+1:])
26+
current = current[(oldIndex + 1):]
27+
}
2828

29-
current += string(vStr)
29+
current += string(vStr)
3030

31-
if len(current) > len(longest) {
32-
longest = current
33-
}
34-
}
31+
if len(current) > len(longest) {
32+
longest = current
33+
}
34+
}
3535

3636
fmt.Printf("\nLongest String: %s", longest)
37-
return len(longest)
37+
return len(longest)
3838
}
3939

4040
func main() {

0 commit comments

Comments
 (0)