일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 운영체제
- LeetCode
- kaggle
- t1
- 시바견
- Convert Sorted List to Binary Search Tree
- 밴픽
- 315. Count of Smaller Numbers After Self
- 109. Convert Sorted List to Binary Search Tree
- 컴퓨터의 구조
- 프로그래머스
- attribute
- data science
- DWG
- iterator
- Substring with Concatenation of All Words
- 715. Range Module
- Python
- shiba
- Class
- 30. Substring with Concatenation of All Words
- 파이썬
- Protocol
- Generator
- Regular Expression
- Decorator
- 43. Multiply Strings
- concurrency
Archives
- Today
- Total
목록Decode Ways (1)
Scribbling
LeetCode: 91. Decode Ways
class Solution: def numDecodings(self, s: str) -> int: candidates = set([str(i) for i in range(1, 27)]) # dp[i] denotes # of ways until s[i-1] dp = [0] * (len(s) + 1) dp[0] = 1 if s[0] in candidates: dp[1] = 1 for i in range(2, len(s)+1): # dp[n] = dp[n-2] * k2 + dp[n-1] * k1 k2 = 0 if s[i-2:i] in candidates: k2 += 1 k1 = 0 if s[i-1] in candidates: k1 += 1 dp[i] = dp[i-2] * k2 + dp[i-1] * k1 ret..
Computer Science/Coding Test
2021. 10. 11. 15:32