leetcode [#118] | GCidea's blog
目录1. 题目2. 解决方案3. 注意事项
题目Given numRows, generate the first numRows of Pascal’s triangle.
Example:given numRows = 5,Return
[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]
解决方案1234567891011121314151617181920public class Solution { public List<List<Integer>> generate(int numRows) { if(numRows == 0) return new ArrayList<List<Integer>>(); List<List<Integer>> result = new ArrayList<List<Integer>>(); for(int i = 1; i <= numRows; i++){ List<Integer>...阅读全文
题目Given numRows, generate the first numRows of Pascal’s triangle.
Example:given numRows = 5,Return
[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]
解决方案1234567891011121314151617181920public class Solution { public List<List<Integer>> generate(int numRows) { if(numRows == 0) return new ArrayList<List<Integer>>(); List<List<Integer>> result = new ArrayList<List<Integer>>(); for(int i = 1; i <= numRows; i++){ List<Integer>...阅读全文