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