题目:https://leetcode-cn.com/problems/pascals-triangle/
答案:
public List<List<Integer>> generate(int numRows) {
List<List<Integer>> lists = new ArrayList<>();
for(int i=1;i<=numRows;i++){
List<Integer> list = new ArrayList<>();
for(int j=1;j<=i;j++){
if(j==1 || j==i){
list.add(1);
}else{
list.add(lists.get(i-2).get(j-2)+lists.get(i-2).get(j-1));
}
}
lists.add(list);
}
return lists;
}