| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 컴퓨터의 구조
- 파이썬
- t1
- LeetCode
- Python
- 프로그래머스
- 시바견
- Python Implementation
- kaggle
- Python Code
- Generator
- 운영체제
- concurrency
- 315. Count of Smaller Numbers After Self
- 30. Substring with Concatenation of All Words
- Protocol
- DWG
- Class
- 43. Multiply Strings
- shiba
- Regular Expression
- data science
- 715. Range Module
- Convert Sorted List to Binary Search Tree
- Substring with Concatenation of All Words
- 밴픽
- attribute
- Decorator
- 109. Convert Sorted List to Binary Search Tree
- iterator
Archives
- Today
- Total
Scribbling
LeetCode: 80. Remove Duplicates from Sorted Array II 본문
Computer Science/Coding Test
LeetCode: 80. Remove Duplicates from Sorted Array II
focalpoint 2021. 10. 6. 14:26class Solution:
def removeDuplicates(self, nums: List[int]) -> int:
reg, freq = None, None
k = 0
for i, num in enumerate(nums):
# update reg & freq
if reg != num:
reg = num
freq = 1
else:
freq += 1
if freq <= 2:
nums[k] = num
k += 1
return k'Computer Science > Coding Test' 카테고리의 다른 글
| LeetCode: 82. Remove Duplicates from Sorted List II (0) | 2021.10.06 |
|---|---|
| LeetCode: 81. Search in Rotated Sorted Array II (0) | 2021.10.06 |
| LeetCode: 84. Largest Rectangle in Histogram (0) | 2021.10.04 |
| LeetCode: 85. Maximal Rectangle (0) | 2021.10.04 |
| LeetCode: 79. Word Search (0) | 2021.10.01 |