标签:tco off shu ref ever -- while offer 数字
链接:https://leetcode-cn.com/problems/ba-shu-zi-fan-yi-cheng-zi-fu-chuan-lcof/submissions/
class Solution {
public:
    int translateNum(int num) {
        int n = 0;
        string s = "";
        while (num) {
            s += to_string(num % 10);
            num /= 10;
            n++;
        }
        reverse(s.begin(), s.end());
        vector<int> f(n + 1);
        f[0] = 1;
        for (int i = 1; i <= n; ++i) {
            f[i] = f[i - 1];
            int t = (s[i - 2]- '0') * 10 + s[i - 1] - '0';
            if (t >= 10 && t <= 25) f[i] += f[i - 2];
        }
        return f[n];
    }
};标签:tco off shu ref ever -- while offer 数字
原文地址:https://www.cnblogs.com/clown9804/p/12426526.html