{"id":4230,"date":"2023-11-07T09:14:49","date_gmt":"2023-11-07T01:14:49","guid":{"rendered":"https:\/\/white-night.club\/?p=4230"},"modified":"2023-11-09T11:07:42","modified_gmt":"2023-11-09T03:07:42","slug":"ad136","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/11\/07\/ad136\/","title":{"rendered":"119.\u00a0\u6768\u8f89\u4e09\u89d2 II\uff08Go\uff09"},"content":{"rendered":"\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u975e\u8d1f\u7d22\u5f15&nbsp;<code>rowIndex<\/code>\uff0c\u8fd4\u56de\u300c\u6768\u8f89\u4e09\u89d2\u300d\u7684\u7b2c&nbsp;<code>rowIndex<\/code><em>&nbsp;<\/em>\u884c\u3002<\/p>\n\n\n\n<p><small>\u5728\u300c\u6768\u8f89\u4e09\u89d2\u300d\u4e2d\uff0c\u6bcf\u4e2a\u6570\u662f\u5b83\u5de6\u4e0a\u65b9\u548c\u53f3\u4e0a\u65b9\u7684\u6570\u7684\u548c\u3002<\/small><\/p>\n\n\n\n<figure class=\"wp-block-image has-custom-border\"><img decoding=\"async\" src=\"https:\/\/pic.leetcode-cn.com\/1626927345-DZmfxB-PascalTriangleAnimated2.gif\" alt=\"\" style=\"border-style:none;border-width:0px;border-radius:0px\"\/><\/figure>\n\n\n\n<p><strong>\u793a\u4f8b 1:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165:<\/strong> rowIndex = 3\n<strong>\u8f93\u51fa:<\/strong> [1,3,3,1]\n<\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 2:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165:<\/strong> rowIndex = 0\n<strong>\u8f93\u51fa:<\/strong> [1]\n<\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 3:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165:<\/strong> rowIndex = 1\n<strong>\u8f93\u51fa:<\/strong> [1,1]\n<\/pre>\n\n\n\n<p><strong>\u63d0\u793a:<\/strong><\/p>\n\n\n\n<ul>\n<li><code>0 &lt;= rowIndex &lt;= 33<\/code><\/li>\n<\/ul>\n\n\n\n<p><strong>\u8fdb\u9636\uff1a<\/strong><\/p>\n\n\n\n<p>\u4f60\u53ef\u4ee5\u4f18\u5316\u4f60\u7684\u7b97\u6cd5\u5230&nbsp;<code><em>O<\/em>(<em>rowIndex<\/em>)<\/code>&nbsp;\u7a7a\u95f4\u590d\u6742\u5ea6\u5417\uff1f<\/p>\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>Go\u4e8c\u7ef4\u6570\u7ec4<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u6768\u8f89\u4e09\u89d2\u5199\u4e86\u597d\u591a\u904d\u4e86\uff0c\u672c\u8eab\u4e5f\u6ca1\u5565\u96be\u7684\u3002\u53cd\u800c\u5728Go\u521b\u5efa\u4e8c\u7ef4\u5207\u7247\u7684\u65f6\u5019\u5361\u4f4f\u4e86&#8230;\u4e0d\u8fc7\u5728Go\u91cc\u9762\u521b\u5efa\u52a8\u6001\u4e8c\u7ef4\u5207\u7247\uff0c\u5176\u5b9e\u548cC++\u91cc\u9762\u521b\u5efa\u52a8\u6001\u4e8c\u7ef4\u6570\u7ec4\u633a\u50cf\u7684\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>func getRow(rowIndex int) &#91;]int {\r\n    result:=make(&#91;]&#91;]int,rowIndex+1)\r\n    for i:=0;i&lt;=rowIndex;i++{\r\n        result&#91;i]=make(&#91;]int,i+1)\r\n    }\r\n    for i:=0;i&lt;=rowIndex;i++{\r\n        result&#91;i]&#91;0]=1\r\n        result&#91;i]&#91;i]=1\r\n        if i>=2{\r\n            for j:=1;j&lt;i;j++{\r\n                result&#91;i]&#91;j]=result&#91;i-1]&#91;j-1]+result&#91;i-1]&#91;j]\r\n            }\r\n        }\r\n    }\r\n    return result&#91;rowIndex]\r\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1aGo\u4e8c\u7ef4\u6570\u7ec4<\/p>\n","protected":false},"author":1,"featured_media":2850,"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\/4230"}],"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=4230"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/4230\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/2850"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=4230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=4230"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=4230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}