-
Notifications
You must be signed in to change notification settings - Fork 0
/
LeetCode_119.java
30 lines (29 loc) · 922 Bytes
/
LeetCode_119.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.util.ArrayList;
import java.util.List;
public class LeetCode_119 {
class Solution {
public List<Integer> getRow(int rowIndex) {
List<Integer> list1 = new ArrayList<>();
list1.add(0);
list1.add(1);
list1.add(0);
List<Integer> last = new ArrayList<>();
last = list1;
for(int i = 1; i <= rowIndex; i ++) {
List<Integer> list2 = new ArrayList<>();
list2.add(0);
int len = last.size();
for(int j = 0; j < len - 1; j ++) {
list2.add(last.get(j) + last.get(j + 1));
}
list2.add(0);
// if(i == rowIndex)
// break;
last = list2;
}
last.remove(0);
last.remove(last.size() - 1);
return last;
}
}
}