1
class Solution {
2
public List<List<Integer>> generate(int numRows) {
3
List<List<Integer>> list = new LinkedList();
4
list.add(Arrays.asList(1));
5
if (numRows == 1) return list;
6
list.add(Arrays.asList(1, 1));
7

8
for (int i = 1; i < numRows - 1; i++) {
9
List<Integer> temp = list.get(i);
10
List<Integer> temp2 = new ArrayList();
11
temp2.add(1);
12
for (int j = 0; j < temp.size() - 1; j++) {
13
temp2.add(temp.get(j) + temp.get(j + 1));
14
}
15
temp2.add(1);
16
list.add(temp2);
17
}
18

19
return list;
20
}
21
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0