标签:com script https class ble decode etc rip length
https://leetcode.com/problems/decode-ways/description/
class Solution { public: int numDecodings(string s) { int n = s.length(); if (n == 0) return 0; vector<int> dp(n, 0); for (int i = 0; i < n; i++) { if (s[i] > ‘0‘ && s[i] <= ‘9‘) dp[i] += i == 0 ? 1 : dp[i-1]; if (i > 0 && (s[i-1] == ‘1‘ || s[i-1] == ‘2‘ && s[i] <= ‘6‘)) dp[i] += i == 1 ? 1 : dp[i-2]; } return dp[n-1]; } };
标签:com script https class ble decode etc rip length
原文地址:https://www.cnblogs.com/JTechRoad/p/9063138.html