Skip to content

Instantly share code, notes, and snippets.

@Siyu-Lei
Created May 22, 2018 23:34
Show Gist options
  • Save Siyu-Lei/46cbc810adb065a22eb525442e056065 to your computer and use it in GitHub Desktop.
Save Siyu-Lei/46cbc810adb065a22eb525442e056065 to your computer and use it in GitHub Desktop.
class Solution {
public List<List<Integer>> generate(int numRows) {
List<List<Integer>> res = new ArrayList();
List<Integer> row = new ArrayList();
for (int i = 0; i < numRows; i++) {
row.add(0, 1);
for (int j = 1; j < row.size() - 1; j++) {
row.set(j, row.get(j) + row.get(j + 1));
}
res.add(new ArrayList(row));
}
return res;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment