力扣118-杨辉三角
题目描述
给定一个非负整数 numRows
,生成「杨辉三角」的前 numRows
行。
在「杨辉三角」中,每个数是它左上方和右上方的数的和。
示例 1:
1 | 输入: numRows = 5 |
示例 2:
1 | 输入: numRows = 1 |
提示:
1 <= numRows <= 30
解题思路
找规律编码即可
代码实现
1 | public class Solution118Case1 { |
给定一个非负整数 numRows
,生成「杨辉三角」的前 numRows
行。
在「杨辉三角」中,每个数是它左上方和右上方的数的和。
示例 1:
1 | 输入: numRows = 5 |
示例 2:
1 | 输入: numRows = 1 |
提示:
1 <= numRows <= 30
找规律编码即可
1 | public class Solution118Case1 { |