{"id":2259,"date":"2022-01-22T14:02:23","date_gmt":"2022-01-22T06:02:23","guid":{"rendered":"http:\/\/139.9.1.231\/?p=2259"},"modified":"2022-01-22T15:08:28","modified_gmt":"2022-01-22T07:08:28","slug":"leetcodeday66","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/01\/22\/leetcodeday66\/","title":{"rendered":"leetcodeday66 &#8211;\u52a01"},"content":{"rendered":"\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u7531&nbsp;<strong>\u6574\u6570&nbsp;<\/strong>\u7ec4\u6210\u7684<strong>&nbsp;\u975e\u7a7a<\/strong>&nbsp;\u6570\u7ec4\u6240\u8868\u793a\u7684\u975e\u8d1f\u6574\u6570\uff0c\u5728\u8be5\u6570\u7684\u57fa\u7840\u4e0a\u52a0\u4e00\u3002<\/p>\n\n\n\n<p>\u6700\u9ad8\u4f4d\u6570\u5b57\u5b58\u653e\u5728\u6570\u7ec4\u7684\u9996\u4f4d\uff0c \u6570\u7ec4\u4e2d\u6bcf\u4e2a\u5143\u7d20\u53ea\u5b58\u50a8<strong>\u5355\u4e2a<\/strong>\u6570\u5b57\u3002<\/p>\n\n\n\n<p>\u4f60\u53ef\u4ee5\u5047\u8bbe\u9664\u4e86\u6574\u6570 0 \u4e4b\u5916\uff0c\u8fd9\u4e2a\u6574\u6570\u4e0d\u4f1a\u4ee5\u96f6\u5f00\u5934\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b&nbsp;1\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>digits = &#91;1,2,3]\n<strong>\u8f93\u51fa\uff1a<\/strong>&#91;1,2,4]\n<strong>\u89e3\u91ca\uff1a<\/strong>\u8f93\u5165\u6570\u7ec4\u8868\u793a\u6570\u5b57 123\u3002<\/code><\/pre>\n\n\n\n<p><strong>\u793a\u4f8b&nbsp;2\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>digits = &#91;4,3,2,1]\n<strong>\u8f93\u51fa\uff1a<\/strong>&#91;4,3,2,2]\n<strong>\u89e3\u91ca\uff1a<\/strong>\u8f93\u5165\u6570\u7ec4\u8868\u793a\u6570\u5b57 4321\u3002<\/code><\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 3\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>digits = &#91;0]\n<strong>\u8f93\u51fa\uff1a<\/strong>&#91;1]<\/code><\/pre>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ul><li><code>1 &lt;= digits.length &lt;= 100<\/code><\/li><li><code>0 &lt;= digits[i] &lt;= 9<\/code><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>#\r\n# &#91;66] \u52a0\u4e00\r\n#\r\n\r\n# @lc code=start\r\nclass Solution:\r\n    def plusOne(self, digits: List&#91;int]) -> List&#91;int]:\r\n        def sub(s):\r\n            s&#91;-1]=s&#91;-1]+1\r\n            i=len(s)-1\r\n            while i>=0:\r\n                if s&#91;0]==10:\r\n                    s=&#91;1,0]+s&#91;1:]\r\n                elif s&#91;i]==10:\r\n                    s&#91;i]=0\r\n                    s&#91;i-1]=s&#91;i-1]+1\r\n                    i=i-1\r\n                else:\r\n\r\n                    return s\r\n        if digits==&#91;9]:\r\n            return &#91;1,0]\r\n        else:\r\n            return sub(digits)<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image is-style-default\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-265.png\" alt=\"\" class=\"wp-image-2260\" width=\"438\" height=\"170\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-265.png 678w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-265-300x116.png 300w\" sizes=\"(max-width: 438px) 100vw, 438px\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u7ed9\u5b9a\u4e00\u4e2a\u7531&nbsp;\u6574\u6570&nbsp;\u7ec4\u6210\u7684&nbsp;\u975e\u7a7a&nbsp;\u6570\u7ec4\u6240\u8868\u793a\u7684\u975e\u8d1f\u6574\u6570\uff0c\u5728\u8be5\u6570\u7684\u57fa\u7840\u4e0a\u52a0 &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/01\/22\/leetcodeday66\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">leetcodeday66 &#8211;\u52a01<\/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\/2259"}],"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=2259"}],"version-history":[{"count":2,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2259\/revisions"}],"predecessor-version":[{"id":2262,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2259\/revisions\/2262"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=2259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=2259"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=2259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}