일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 30. Substring with Concatenation of All Words
- 시바견
- data science
- Python Code
- 315. Count of Smaller Numbers After Self
- 컴퓨터의 구조
- 운영체제
- 43. Multiply Strings
- DWG
- shiba
- attribute
- Python
- 715. Range Module
- 프로그래머스
- concurrency
- 파이썬
- kaggle
- Protocol
- Generator
- LeetCode
- Convert Sorted List to Binary Search Tree
- 109. Convert Sorted List to Binary Search Tree
- Decorator
- iterator
- Substring with Concatenation of All Words
- Regular Expression
- 밴픽
- Python Implementation
- Class
Archives
- Today
- Total
목록238. Product of Array Except Self (1)
Scribbling
LeetCode: 238. Product of Array Except Self
Relatively straightforward solution, O(N) time O(1) Memory. class Solution: def productExceptSelf(self, nums: List[int]) -> List[int]: numZero, prod, zeroidx = 0, 1, 0 for i, num in enumerate(nums): if num == 0: numZero += 1 zeroidx = i else: prod *= num if numZero >= 2: return [0] * len(nums) if numZero == 1: ret = [0] * len(nums) ret[zeroidx] = prod return ret # backward pass ret = [0] * len(n..
Computer Science/Coding Test
2021. 11. 25. 11:14