{"id":2429,"date":"2022-01-26T20:37:03","date_gmt":"2022-01-26T12:37:03","guid":{"rendered":"http:\/\/139.9.1.231\/?p=2429"},"modified":"2022-01-26T20:37:04","modified_gmt":"2022-01-26T12:37:04","slug":"leetcodeday91","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/01\/26\/leetcodeday91\/","title":{"rendered":"leetcodeday91 &#8211;\u89e3\u7801\u65b9\u6cd5"},"content":{"rendered":"\n<p>\u4e00\u6761\u5305\u542b\u5b57\u6bcd&nbsp;<code>A-Z<\/code>&nbsp;\u7684\u6d88\u606f\u901a\u8fc7\u4ee5\u4e0b\u6620\u5c04\u8fdb\u884c\u4e86&nbsp;<strong>\u7f16\u7801<\/strong>&nbsp;\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>'A' -&gt; 1\n'B' -&gt; 2\n...\n'Z' -&gt; 26<\/code><\/pre>\n\n\n\n<p>\u8981&nbsp;<strong>\u89e3\u7801<\/strong>&nbsp;\u5df2\u7f16\u7801\u7684\u6d88\u606f\uff0c\u6240\u6709\u6570\u5b57\u5fc5\u987b\u57fa\u4e8e\u4e0a\u8ff0\u6620\u5c04\u7684\u65b9\u6cd5\uff0c\u53cd\u5411\u6620\u5c04\u56de\u5b57\u6bcd\uff08\u53ef\u80fd\u6709\u591a\u79cd\u65b9\u6cd5\uff09\u3002\u4f8b\u5982\uff0c<code>\"11106\"<\/code>&nbsp;\u53ef\u4ee5\u6620\u5c04\u4e3a\uff1a<\/p>\n\n\n\n<ul><li><code>\"AAJF\"<\/code>&nbsp;\uff0c\u5c06\u6d88\u606f\u5206\u7ec4\u4e3a&nbsp;<code>(1 1 10 6)<\/code><\/li><li><code>\"KJF\"<\/code>&nbsp;\uff0c\u5c06\u6d88\u606f\u5206\u7ec4\u4e3a&nbsp;<code>(11 10 6)<\/code><\/li><\/ul>\n\n\n\n<p>\u6ce8\u610f\uff0c\u6d88\u606f\u4e0d\u80fd\u5206\u7ec4\u4e3a&nbsp;&nbsp;<code>(1 11 06)<\/code>&nbsp;\uff0c\u56e0\u4e3a&nbsp;<code>\"06\"<\/code>&nbsp;\u4e0d\u80fd\u6620\u5c04\u4e3a&nbsp;<code>\"F\"<\/code>&nbsp;\uff0c\u8fd9\u662f\u7531\u4e8e&nbsp;<code>\"6\"<\/code>&nbsp;\u548c&nbsp;<code>\"06\"<\/code>&nbsp;\u5728\u6620\u5c04\u4e2d\u5e76\u4e0d\u7b49\u4ef7\u3002<\/p>\n\n\n\n<p>\u7ed9\u4f60\u4e00\u4e2a\u53ea\u542b\u6570\u5b57\u7684&nbsp;<strong>\u975e\u7a7a&nbsp;<\/strong>\u5b57\u7b26\u4e32&nbsp;<code>s<\/code>&nbsp;\uff0c\u8bf7\u8ba1\u7b97\u5e76\u8fd4\u56de&nbsp;<strong>\u89e3\u7801<\/strong>&nbsp;\u65b9\u6cd5\u7684&nbsp;<strong>\u603b\u6570<\/strong>&nbsp;\u3002<\/p>\n\n\n\n<p>\u9898\u76ee\u6570\u636e\u4fdd\u8bc1\u7b54\u6848\u80af\u5b9a\u662f\u4e00\u4e2a&nbsp;<strong>32 \u4f4d<\/strong>&nbsp;\u7684\u6574\u6570\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>s = \"12\"\n<strong>\u8f93\u51fa\uff1a<\/strong>2\n<strong>\u89e3\u91ca\uff1a<\/strong>\u5b83\u53ef\u4ee5\u89e3\u7801\u4e3a \"AB\"\uff081 2\uff09\u6216\u8005 \"L\"\uff0812\uff09\u3002<\/code><\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 2\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>s = \"226\"\n<strong>\u8f93\u51fa\uff1a<\/strong>3\n<strong>\u89e3\u91ca\uff1a<\/strong>\u5b83\u53ef\u4ee5\u89e3\u7801\u4e3a \"BZ\" (2 26), \"VF\" (22 6), \u6216\u8005 \"BBF\" (2 2 6) \u3002<\/code><\/pre>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u601d\u8def\uff1a\u52a8\u6001\u89c4\u5212\u65b9\u6cd5<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># &#91;91] \u89e3\u7801\u65b9\u6cd5\r\n#\u52a8\u6001\u89c4\u5212\r\n#dp\u3010i\u3011\u8868\u793a\u4ece0-i\u4e2a\u6570\u5b57\u8868\u793a\u7684\u6620\u5c04\u6570\r\n\r\n# @lc code=start\r\nclass Solution:\r\n    def numDecodings(self, s: str) -> int:\r\n        lens=len(s)\r\n        dp=&#91;0 for _ in range(lens)]\r\n        if s&#91;0]!=\"0\":\r\n            dp&#91;0]=1\r\n        else:\r\n            return 0\r\n        if len(s)==1:\r\n            return dp&#91;0]\r\n        else:\r\n            x=1 if s&#91;1]!=\"0\" and dp&#91;0]!=0 else 0\r\n            y=1 if int(s&#91;0:2]) in range(10,27) else 0\r\n            dp&#91;1]=x+y\r\n        for i in range(2,lens):\r\n            x=dp&#91;i-1] if s&#91;i]!=\"0\" and dp&#91;i-1]!=0 else 0\r\n            y=dp&#91;i-2] if int(s&#91;i-1:i+1]) in range(10,27) else 0\r\n            dp&#91;i]=x+y\r\n        return dp&#91;lens-1]\r\n\r\n        \r\n\r\n# @lc code=end<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" width=\"888\" height=\"263\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-299.png\" alt=\"\" class=\"wp-image-2430\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-299.png 888w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-299-300x89.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-299-768x227.png 768w\" sizes=\"(max-width: 888px) 100vw, 888px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u6761\u5305\u542b\u5b57\u6bcd&nbsp;A-Z&nbsp;\u7684\u6d88\u606f\u901a\u8fc7\u4ee5\u4e0b\u6620\u5c04\u8fdb\u884c\u4e86&nbsp;\u7f16\u7801&nbsp;\uff1a \u8981&#038;nbsp &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/01\/26\/leetcodeday91\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">leetcodeday91 &#8211;\u89e3\u7801\u65b9\u6cd5<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2429"}],"collection":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/comments?post=2429"}],"version-history":[{"count":3,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2429\/revisions"}],"predecessor-version":[{"id":2433,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2429\/revisions\/2433"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=2429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=2429"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=2429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}