{"id":2638,"date":"2023-10-16T11:32:59","date_gmt":"2023-10-16T03:32:59","guid":{"rendered":"https:\/\/white-night.club\/?p=2638"},"modified":"2023-11-09T11:07:49","modified_gmt":"2023-11-09T03:07:49","slug":"ad59","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/16\/ad59\/","title":{"rendered":"1480.\u00a0\u4e00\u7ef4\u6570\u7ec4\u7684\u52a8\u6001\u548c"},"content":{"rendered":"\n<p>\u7ed9\u4f60\u4e00\u4e2a\u6570\u7ec4\u00a0<code>nums<\/code>\u00a0\u3002\u6570\u7ec4\u300c\u52a8\u6001\u548c\u300d\u7684\u8ba1\u7b97\u516c\u5f0f\u4e3a\uff1a<code>runningSum[i] = sum(nums[0]\u2026nums[i])<\/code>\u00a0\u3002<\/p>\n\n\n\n<p>\u8bf7\u8fd4\u56de&nbsp;<code>nums<\/code>&nbsp;\u7684\u52a8\u6001\u548c\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>nums = [1,2,3,4]\n<strong>\u8f93\u51fa\uff1a<\/strong>[1,3,6,10]\n<strong>\u89e3\u91ca\uff1a<\/strong>\u52a8\u6001\u548c\u8ba1\u7b97\u8fc7\u7a0b\u4e3a [1, 1+2, 1+2+3, 1+2+3+4] \u3002<\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 2\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>nums = [1,1,1,1,1]\n<strong>\u8f93\u51fa\uff1a<\/strong>[1,2,3,4,5]\n<strong>\u89e3\u91ca\uff1a<\/strong>\u52a8\u6001\u548c\u8ba1\u7b97\u8fc7\u7a0b\u4e3a [1, 1+1, 1+1+1, 1+1+1+1, 1+1+1+1+1] \u3002<\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 3\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>nums = [3,1,2,10,1]\n<strong>\u8f93\u51fa\uff1a<\/strong>[3,4,6,16,17]\n<\/pre>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li><code>1 &lt;= nums.length &lt;= 1000<\/code><\/li>\n\n\n\n<li><code>-10^6&nbsp;&lt;= nums[i] &lt;=&nbsp;10^6<\/code><\/li>\n<\/ul>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u89e3\u9898\u601d\u8def<\/p>\n<cite><em>\u524d\u7f00\u548c<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u8fd8\u662f\u8ba1\u7b97\u524d\u7f00\u548c\uff0c\u4e0d\u8fc7\u524d\u7f00\u548c\u6570\u7ec4sum\u7684\u5927\u5c0f\u8981\u548c\u539f\u6570\u7ec4\u4e00\u81f4\uff0c\u6240\u4ee5\u4e0b\u6807\u8981\u4ece1\u5f00\u59cb\u7b97\u8d77\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Solution {\r\npublic:\r\n    vector&lt;int> runningSum(vector&lt;int>&amp; nums) {\r\n        vector&lt;int>sum;\r\n        int size=nums.size();\r\n        sum.resize(size);\r\n        sum&#91;0]=nums&#91;0];\r\n        for(int i=1;i&lt;size;i++)\r\n        {\r\n            sum&#91;i]=sum&#91;i-1]+nums&#91;i];\r\n        }\r\n        \r\n        return sum;\r\n    }\r\n};<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a\u524d\u7f00\u548c<\/p>\n","protected":false},"author":1,"featured_media":2827,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[42,25],"tags":[38],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2638"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=2638"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2638\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/2827"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=2638"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=2638"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=2638"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}