<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                **一. 題目描述** A message containing letters from A-Z is being encoded to numbers using the following mapping: ~~~ 'A' -> 1 'B' -> 2 ... 'Z' -> 26 ~~~ Given an encoded message containing digits, determine the total number of ways to decode it.? For example, Given encoded message “12”, it could be decoded as “AB” (1 2) or “L” (12).? The number of ways decoding “12” is 2. **二. 題目分析** 題目的大意是,給你一串數字,解碼成相應的英文字母。類似爬樓梯問題Climbing Stairs,可使用動態規劃來完成。 **三. 示例代碼** ~~~ #include <iostream> #include <string> using namespace std; class Solution { public: int numDecodings(const string &s) { if (s.empty() || s[0] == '0') return 0; int prev = 0; int cur = 1; // 長度為 n 的字符串,有 n+1 個階梯 for (size_t i = 1; i <= s.size(); ++i) { if (s[i-1] == '0') cur = 0; if (i < 2 || !(s[i - 2] == '1' || (s[i - 2] == '2' && s[i - 1] <= '6'))) prev = 0; int tmp = cur; cur = prev + cur; prev = tmp; } return cur; } }; ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看