1class Solution {2public List<Integer> getRow(int rowIndex) {3List<List<Integer>> out = new ArrayList<>();4for (int i = 0; i <= rowIndex; i++) {5List<Integer> in = new ArrayList<>(i + 1);6for (int j = 0; j <= i; j++) {7if (j == 0 || j == i) {8in.add(1);9} else {10in.add(out.get(i - 1).get(j - 1) + out.get(i - 1).get(j));11}12}13out.add(in);14}15return out.get(rowIndex);16}17}