Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1cec749

Browse files
authored
Update 128.longest-consecutive-sequence.md
1 parent a5b23ab commit 1cec749

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

problems/128.longest-consecutive-sequence.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ var longestConsecutive = function(nums) {
8181
let max = 0;
8282
let temp = 0;
8383
set.forEach(x => {
84-
// 说明x是连续序列的开头元素
84+
// 说明x是连续序列的开头元素。加这个条件相当于剪枝的作用,否则时间复杂度会退化到 N ^ 2
8585
if (!set.has(x - 1)) {
8686
temp = x + 1;
8787
while (set.has(y)) {

0 commit comments

Comments
 (0)