File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 16
16
},
17
17
"python.testing.pytestArgs" : [" solutions" ],
18
18
"python.testing.unittestEnabled" : false ,
19
- "python.testing.pytestEnabled" : true
19
+ "python.testing.pytestEnabled" : true ,
20
+ "github.copilot.enable" : {
21
+ "python" : " false"
22
+ }
20
23
}
Original file line number Diff line number Diff line change 1
1
class Solution :
2
- def longestConsecutive (self , nums : list [int ]) -> int : ...
2
+ def longestConsecutive (self , nums : list [int ]) -> int :
3
+ num_set = set (nums )
4
+ max_length = 0
5
+
6
+ for num in num_set :
7
+ if num - 1 not in num_set :
8
+ current_num = num
9
+ current_length = 1
10
+
11
+ while current_num + 1 in num_set :
12
+ current_num += 1
13
+ current_length += 1
14
+
15
+ max_length = max (max_length , current_length )
16
+
17
+ return max_length
You can’t perform that action at this time.
0 commit comments