瀏覽代碼

finish 'Longest Substring Without Repeating Characters'

tangs 5 年之前
父節點
當前提交
7158263b53
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      tags/string/longestSubstringWithoutRepeatingCharacters/main.go

+ 1 - 1
tags/string/longestSubstringWithoutRepeatingCharacters/main.go

@@ -54,7 +54,7 @@ func lengthOfLongestSubstring(s string) int {
 		if i-cursor > maxCount {
 			maxCount = i - cursor
 		}
-		cursor++
+		cursor = record[s[i]] + 1
 		record[s[i]] = i
 
 	}