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