1class Solution {2public List<List<Integer>> generate(int numRows) {3List<List<Integer>> list = new LinkedList();4list.add(Arrays.asList(1));5if (numRows == 1) return list;6list.add(Arrays.asList(1, 1));78for (int i = 1; i < numRows - 1; i++) {9List<Integer> temp = list.get(i);10List<Integer> temp2 = new ArrayList();11temp2.add(1);12for (int j = 0; j < temp.size() - 1; j++) {13temp2.add(temp.get(j) + temp.get(j + 1));14}15temp2.add(1);16list.add(temp2);17}1819return list;20}21}