일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- Python Implementation
- Python Code
- Protocol
- Decorator
- 109. Convert Sorted List to Binary Search Tree
- 밴픽
- t1
- Substring with Concatenation of All Words
- 715. Range Module
- DWG
- 프로그래머스
- iterator
- Generator
- data science
- 30. Substring with Concatenation of All Words
- shiba
- 43. Multiply Strings
- Convert Sorted List to Binary Search Tree
- 시바견
- LeetCode
- kaggle
- 컴퓨터의 구조
- attribute
- Class
- 파이썬
- 운영체제
- Regular Expression
- 315. Count of Smaller Numbers After Self
- Python
- concurrency
Archives
- Today
- Total
Scribbling
LeetCode: 442. Find All Duplicates in an Array 본문
Computer Science/Coding Test
LeetCode: 442. Find All Duplicates in an Array
focalpoint 2022. 1. 5. 11:08O(N), O(1) Solution by using input array as a memory.
class Solution:
def findDuplicates(self, nums: List[int]) -> List[int]:
ret = []
for i, num in enumerate(nums):
if nums[abs(num) - 1] < 0:
ret.append(abs(num))
nums[abs(num) - 1] *= -1
return ret
'Computer Science > Coding Test' 카테고리의 다른 글
LeetCode: 322. Coin Change (0) | 2022.01.07 |
---|---|
LeetCode: 21. Merge Two Sorted Lists (0) | 2022.01.05 |
LeetCode: 268. Missing Number (0) | 2022.01.04 |
LeetCode: 1010. Pairs of Songs With Total Durations Divisible by 60 (0) | 2022.01.03 |
LeetCode: 297. Serialize and Deserialize Binary Tree (0) | 2022.01.02 |