```
public List<List<Integer>> generate(int numRows) {
List<List<Integer>> result = new LinkedList<>();
for (int i = 0; i < numRows; i++) {
List<Integer> row = new ArrayList<>();
int s = 1;
for (int j = 0; j <= i; j++) {
row.add(s);
s = s * (i - j) / (j + 1);
}
result.add(row);
}
return result;
}
```

Just use the formula of binomial coefficient nCr+1 = nCr * (n -r) / (r + 1)