Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2a49187

Browse files
🐱(array): 118. 杨辉三角
补充 python 题解
1 parent 978f347 commit 2a49187

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎docs/data-structure/array/README.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,23 @@ class Solution(object):
10891089

10901090
优化:
10911091

1092+
#### **Python**
1093+
1094+
```python
1095+
class Solution:
1096+
def generate(self, numRows: int) -> List[List[int]]:
1097+
ans = []
1098+
for i in range(numRows):
1099+
tmp = [1 for _ in range(i + 1)]
1100+
for j in range(1, i):
1101+
tmp[j] = ans[i - 1][j - 1] + ans[i - 1][j]
1102+
ans.append(tmp)
1103+
1104+
return ans
1105+
```
1106+
1107+
#### **Go**
1108+
10921109
```go
10931110
func generate(numRows int) [][]int {
10941111
var res [][]int = make([][]int, numRows)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /