Skip to content

Commit 6f84790

Browse files
committed
refactor: remove duplicate check
1 parent 166af3d commit 6f84790

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

β€Žlongest-consecutive-sequence/tolluset.tsβ€Ž

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,10 @@ function longestConsecutive(nums: number[]): number {
2828

2929
const isConsecutive = isLeft || isRight;
3030

31-
if (isConsecutive) {
31+
if (isConsecutive && (!isLeft || isRight)) {
3232
bucket[cursor].add(current);
33-
34-
if (isLeft && !isRight) {
35-
cursor++;
36-
}
3733
} else {
3834
cursor++;
39-
40-
continue;
4135
}
4236
}
4337

@@ -59,4 +53,4 @@ const t3 = longestConsecutive([9, 1, 4, 7, 3, -1, 0, 5, 8, -1, 6]);
5953
console.info("πŸš€ : tolluset.ts:40: t3=", t3); // 7
6054

6155
const t4 = longestConsecutive([-6, -1, -1, 9, -8, -6, -6, 4, 4, -3, -8, -1]);
62-
console.info("πŸš€ : tolluset.ts:59: t4=", t4); //1
56+
console.info("πŸš€ : tolluset.ts:59: t4=", t4); // 1

0 commit comments

Comments
Β (0)