일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
Tags
- Regular Expression
- Generator
- 715. Range Module
- t1
- Python Code
- attribute
- Substring with Concatenation of All Words
- 운영체제
- Python
- 30. Substring with Concatenation of All Words
- 315. Count of Smaller Numbers After Self
- kaggle
- Protocol
- Class
- LeetCode
- Decorator
- concurrency
- DWG
- 시바견
- data science
- shiba
- Convert Sorted List to Binary Search Tree
- 파이썬
- 43. Multiply Strings
- Python Implementation
- 프로그래머스
- 109. Convert Sorted List to Binary Search Tree
- 컴퓨터의 구조
- iterator
- 밴픽
Archives
- Today
- Total
목록Longest Consecutive Sequence (1)
Scribbling
LeetCode: 128. Longest Consecutive Sequence
O(N) 알고리즘. class Solution: def longestConsecutive(self, nums: List[int]) -> int: longest = 0 nums = set(nums) for num in nums: if num - 1 not in nums: cnt = 1 while num + 1 in nums: num += 1 cnt += 1 longest = max(longest, cnt) return longest class Solution: def longestConsecutive(self, nums: List[int]) -> int: numSet = set(nums) longest = 0 while nums: cnt = 1 l = r = nums.pop() numSet.discard(..
Computer Science/Coding Test
2021. 11. 8. 21:36