Skip to content

Commit c8dae29

Browse files
committed
refactor Longest Substring Without Repeating Characters
1 parent 544e7e9 commit c8dae29

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

go/longest_substring_without_repeating_characters.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ package main
33

44
func lengthOfLongestSubstring(s string) int {
55
maxLen, head := 0, 0
6-
using := make(map[byte]struct{})
6+
inUse := make(map[byte]struct{})
77
for tail := range s {
8-
if _, ok := using[s[tail]]; ok {
8+
if _, ok := inUse[s[tail]]; ok {
99
for s[head] != s[tail] {
10-
delete(using, s[head])
10+
delete(inUse, s[head])
1111
head++
1212
}
1313
head++
1414
} else {
15-
using[s[tail]] = struct{}{}
15+
inUse[s[tail]] = struct{}{}
1616
}
1717
maxLen = max(maxLen, tail-head+1)
1818
}

0 commit comments

Comments
 (0)