{"id":2810,"date":"2023-10-18T09:41:33","date_gmt":"2023-10-18T01:41:33","guid":{"rendered":"https:\/\/white-night.club\/?p=2810"},"modified":"2023-11-09T11:07:48","modified_gmt":"2023-11-09T03:07:48","slug":"ad71","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/18\/ad71\/","title":{"rendered":"1732.\u00a0\u627e\u5230\u6700\u9ad8\u6d77\u62d4"},"content":{"rendered":"\n<p>\u6709\u4e00\u4e2a\u81ea\u884c\u8f66\u624b\u6253\u7b97\u8fdb\u884c\u4e00\u573a\u516c\u8def\u9a91\u884c\uff0c\u8fd9\u6761\u8def\u7ebf\u603b\u5171\u7531&nbsp;<code>n + 1<\/code>&nbsp;\u4e2a\u4e0d\u540c\u6d77\u62d4\u7684\u70b9\u7ec4\u6210\u3002\u81ea\u884c\u8f66\u624b\u4ece\u6d77\u62d4\u4e3a&nbsp;<code>0<\/code>&nbsp;\u7684\u70b9&nbsp;<code>0<\/code>&nbsp;\u5f00\u59cb\u9a91\u884c\u3002<\/p>\n\n\n\n<p>\u7ed9\u4f60\u4e00\u4e2a\u957f\u5ea6\u4e3a&nbsp;<code>n<\/code>&nbsp;\u7684\u6574\u6570\u6570\u7ec4&nbsp;<code>gain<\/code>&nbsp;\uff0c\u5176\u4e2d&nbsp;<code>gain[i]<\/code>&nbsp;\u662f\u70b9&nbsp;<code>i<\/code>&nbsp;\u548c\u70b9&nbsp;<code>i + 1<\/code>&nbsp;\u7684&nbsp;<strong>\u51c0\u6d77\u62d4\u9ad8\u5ea6\u5dee<\/strong>\uff08<code>0 &lt;= i &lt; n<\/code>\uff09\u3002\u8bf7\u4f60\u8fd4\u56de&nbsp;<strong>\u6700\u9ad8\u70b9\u7684\u6d77\u62d4<\/strong>&nbsp;\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>gain = [-5,1,5,0,-7]\n<strong>\u8f93\u51fa\uff1a<\/strong>1\n<strong>\u89e3\u91ca\uff1a<\/strong>\u6d77\u62d4\u9ad8\u5ea6\u4f9d\u6b21\u4e3a [0,-5,-4,1,1,-6] \u3002\u6700\u9ad8\u6d77\u62d4\u4e3a 1 \u3002\n<\/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>gain = [-4,-3,-2,-1,4,3,2]\n<strong>\u8f93\u51fa\uff1a<\/strong>0\n<strong>\u89e3\u91ca\uff1a<\/strong>\u6d77\u62d4\u9ad8\u5ea6\u4f9d\u6b21\u4e3a [0,-4,-7,-9,-10,-6,-3,-1] \u3002\u6700\u9ad8\u6d77\u62d4\u4e3a 0 \u3002\n<\/pre>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li><code>n == gain.length<\/code><\/li>\n\n\n\n<li><code>1 &lt;= n &lt;= 100<\/code><\/li>\n\n\n\n<li><code>-100 &lt;= gain[i] &lt;= 100<\/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\u6c42\u524d\u7f00\u548c\u7684\u9898\u3002\u8fd9\u6b21\u8bd5\u7740\u7528go\u5199\u4e86\u4e0b\uff0c\u4e3b\u8981\u662f\u9002\u5e94\u4e00\u4e0bgo\u8bed\u8a00\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>func largestAltitude(gain &#91;]int) int {\n    var size=len(gain)\n    var sum=make(&#91;]int,size+1)\n    for i:=0;i&lt;size;i++{\n        sum&#91;i+1]=sum&#91;i]+gain&#91;i]\n    }\n    var max=-100;\n    for i:=0;i&lt;=size;i++{\n        if sum&#91;i]&gt;max{\n            max=sum&#91;i]\n        }\n    }\n    return max;\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\/2810"}],"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=2810"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2810\/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=2810"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=2810"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=2810"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}