Created
May 22, 2018 23:34
-
-
Save Siyu-Lei/46cbc810adb065a22eb525442e056065 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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