
Decode Ways
·
PS/LeetCode
문제https://leetcode.com/problems/decode-ways/description/입력1 결과ans: Int = 주어진 s를 알파벳으로 디코딩할 수 있는 경우의 수해석동전 문제와 비슷하게 해석할 수 있다.여기서 제약조건은 알파벳은 1 ~ 26까지 대응되며, 01 , 02 같은 형태는 없는 형태이다. 코드extension String { subscript(_ index: Int) -> String { return String(self[self.index(self.startIndex, offsetBy: index)]) }}class Solution { func numDecodings(_ s: String) -> Int { guard !s.isEmpty..