# Pascal's Triangle I&II

lpy1990

## 118 Pascal's Triangle

### 代码

``````public class Solution {
public List<List<Integer>> generate(int numRows) {
List<List<Integer>> res = new ArrayList<>();
if (numRows<=0) {return res;}
for (int i = 0; i <numRows; i++) {
List<Integer> tmp = new ArrayList<>();
for (int j = 1; j< i; j++) {//从第三行开始加入中间的数字
}
if (i > 0) {//每行最后一个数字
}
}
return res;
}
}``````

## 119. Pascal's Triangle II

### 代码

``````class Solution {
public List<Integer> getRow(int rowIndex) {
List<Integer> res = new ArrayList<>();
if (rowIndex<0) {return res;}
for (int i = 0; i <=rowIndex; i++) {
List<Integer> list = new ArrayList<>();
for (int j = 1; j< i; j++) {//从第三行开始加入中间的数字
}
if (i > 0) {//每行最后一个数字
}
res = list;
}
return res;
}
}
``````

### 代码

``````class Solution {
public List<Integer> getRow(int rowIndex) {
List<Integer> res = new ArrayList<>();
if (rowIndex<0) {return res;}
for (int i = 0; i <rowIndex; i++) {
for (int j = res.size() - 1;  j >0; j--) {
res.set(j, res.get(j) + res.get(j-1));
}