일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 715. Range Module
- iterator
- 파이썬
- Convert Sorted List to Binary Search Tree
- Protocol
- shiba
- Substring with Concatenation of All Words
- 43. Multiply Strings
- 30. Substring with Concatenation of All Words
- Python Code
- 운영체제
- LeetCode
- 315. Count of Smaller Numbers After Self
- Generator
- Regular Expression
- data science
- Python Implementation
- 컴퓨터의 구조
- concurrency
- 시바견
- Python
- Decorator
- 밴픽
- Class
- kaggle
- attribute
- DWG
- 프로그래머스
- 109. Convert Sorted List to Binary Search Tree
- t1
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