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