Problem#7 : Decoding Possibility
2020. 8. 15. 23:01ㆍPS/도전
All problems are from https://www.dailycodingproblem.com/
Solution Codes : https://github.com/Kusin/DailyCoding
Daily Coding Problem#7 : Decoding Possibility
Problem Description
Idea
Dynamic Programming.
DP(i) : number of decodings possible from str[0:i]
DP(i) = DP(i-1) or DP(i-1) + DP(i-2)
DP(i-2) is added if 1<=int(str[i-2:2]) <=26 and str[i-2] != '0'
which means str[i-2:2] is a valid alphabet.
Implementation
code:
728x90
'PS > 도전' 카테고리의 다른 글
Problem#9 : Non-Adjacent Sum (0) | 2020.08.16 |
---|---|
Problem#8 :Unival Subtrees (0) | 2020.08.16 |
Problem #6 XOR Linked List (0) | 2020.08.15 |
Problem #5 Implementing Pair in Python (0) | 2020.08.15 |
Problem #4 : First missing positive integer (0) | 2020.08.15 |