Skip to content

Commit

Permalink
chore: 增加一行注释
Browse files Browse the repository at this point in the history
  • Loading branch information
luzhipeng committed Jun 19, 2019
1 parent f651ec4 commit 53313e5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion problems/128.longest-consecutive-sequence.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,13 @@ var longestConsecutive = function(nums) {
let max = 0;
let y = 0;
nums.forEach(x => {
// 说明x是连续序列的开头元素
if (!nums.has(x - 1)) {
y = x + 1;
while (nums.has(y)) {
y = y + 1;
}
max = Math.max(max, y - x); // y - x 就是从i开始到最后有多少连续的数字
max = Math.max(max, y - x); // y - x 就是从x开始到最后有多少连续的数字
}
});
return max;
Expand Down

0 comments on commit 53313e5

Please sign in to comment.