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