일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 프로그래머스
- DWG
- 밴픽
- Decorator
- concurrency
- shiba
- data science
- Substring with Concatenation of All Words
- kaggle
- Python Code
- 시바견
- 컴퓨터의 구조
- 파이썬
- 109. Convert Sorted List to Binary Search Tree
- attribute
- 315. Count of Smaller Numbers After Self
- Class
- Regular Expression
- Generator
- LeetCode
- Protocol
- 43. Multiply Strings
- Python
- Convert Sorted List to Binary Search Tree
- t1
- 운영체제
- iterator
- Python Implementation
- 715. Range Module
- 30. Substring with Concatenation of All Words
Archives
- Today
- Total
목록135. Candy (1)
Scribbling
LeetCode: 135. Candy
Key idea: one's number of candies is affected by all the left and right neighbors. So we iterate the list twice, forward and backward. class Solution: def candy(self, ratings: List[int]) -> int: n = len(ratings) candies = [1] * n # forward pass for i in range(1, n): if ratings[i] > ratings[i-1]: candies[i] = candies[i-1] + 1 # backward pass for i in range(n-2, -1, -1): if ratings[i] > ratings[i+..
Computer Science/Coding Test
2022. 2. 3. 10:35