leetcode118.杨辉三角
思路源自
【LeetCode 每日一题】118. 杨辉三角 | 手写图解版思路 + 代码讲解
class Solution {
public List<List<Integer>> generate(int numRows) {
List<List<Integer>> result = new ArrayList<>();
for (int i = 0; i < numRows; i++) {
List<Integer> list = new ArrayList<>(Collections.nCopies(i + 1, 1));
for (int j = 1; j < i; j++) {
list.set(j, result.get(i - 1).get(j - 1) + result.get(i-1).get(j));
}
result.add(i, list);
}
return result;
}
}