[Leetcode - Medium] Decode Ways #51
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
문제
Constraints
1 <= s.length <= 100scontains only digits and may contain leading zero(s).Edge Case
풀이
아이디어 도출로 순식간에 해결된 문제라 기존 문제들과는 풀이가 다를 수 있습니다..
문제 정의를 한 줄로 해보자면 다음과 같습니다.
알파벳은 1~26(
A~Z)까지 치환이 가능하므로 1자리 수 혹은 2자리 수의 알파벳으로 주어진 문자열을 만드는 과정, 즉 #25 문제와 동일하다는 것을 알 수 있습니다.dp[n] = dp[n-1] + dp[n-2]하지만 다음과 같이 숫자를 알파벳으로 치환할 수 없는 경우가 존재합니다.
로직을 정리해보면 문제 해결 끄읏!
어려웠던 점
알게된 점