标签:style blog color io ar for div sp log
public class Solution { public List<List<Integer>> generate(int numRows) { List<List<Integer>> result = new ArrayList<List<Integer>>(); if (numRows <=0) return result; ArrayList<Integer> oldLine = new ArrayList<Integer>(); oldLine.add(1); result.add(oldLine); for (int i=1; i<numRows; i++) { ArrayList<Integer> newLine = new ArrayList<Integer>(); newLine.add(1); for (int j=1; j<i; j++) { newLine.add(oldLine.get(j-1)+oldLine.get(j)); } newLine.add(1); result.add(newLine); oldLine = newLine; } return result; } }
标签:style blog color io ar for div sp log
原文地址:http://www.cnblogs.com/yuhaos/p/3955183.html