일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- data science
- kaggle
- 운영체제
- 파이썬
- Decorator
- attribute
- 715. Range Module
- 프로그래머스
- Protocol
- 43. Multiply Strings
- Generator
- Regular Expression
- iterator
- Class
- 30. Substring with Concatenation of All Words
- 밴픽
- 315. Count of Smaller Numbers After Self
- Python Code
- 컴퓨터의 구조
- 109. Convert Sorted List to Binary Search Tree
- DWG
- Python Implementation
- shiba
- t1
- Convert Sorted List to Binary Search Tree
- concurrency
- LeetCode
- Substring with Concatenation of All Words
- Python
- 시바견
Archives
- Today
- Total
목록LeetCode 128. Longest Consecutive Sequence (1)
Scribbling
[C++] LeetCode 128. Longest Consecutive Sequence
https://leetcode.com/problems/longest-consecutive-sequence/ class Solution { public: int longestConsecutive(vector& nums) { int ret = 0; unordered_set num_set(nums.begin(), nums.end()); for (int num : nums) { // not found if (num_set.find(num - 1) == num_set.end()) { int cnt = 0; while (num_set.find(num) != num_set.end()) { num += 1; cnt += 1; } ret = max(ret, cnt); } } return ret; } };
Computer Science/C++
2023. 8. 18. 06:48