1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| class Solution { public List<Integer> getRow(int rowIndex) { List<Integer> list = new ArrayList<>(rowIndex + 1); list.add(1);
for (int i = 1; i <= rowIndex; i++) { list.add(1); for (int j = i - 1; j >= 1; j--) { list.set(j, list.get(j - 1) + list.get(j)); } }
return list; } }
|
References
119. Pascal’s Triangle II