Skip to content

Commit 230f6cb

Browse files
author
Jinbeom
committed
파일위치 변경
1 parent 9db56f3 commit 230f6cb

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# 시간복잡도: O(N)
2+
# 공간복잡도: O(N)
3+
class Solution:
4+
def longestConsecutive(self, nums: List[int]) -> int:
5+
nums = set(nums)
6+
answer = 0
7+
8+
for num in nums:
9+
if num - 1 not in nums:
10+
length = 1
11+
12+
while num + length in nums:
13+
length += 1
14+
15+
answer = max(answer, length)
16+
17+
return answer

0 commit comments

Comments
 (0)