public List<Integer> getRow(int rowIndex) {
List<Integer> rlist = new ArrayList<Integer>();
List<Integer> temp = new ArrayList<Integer>();
if(rowIndex==0){
rlist.add(1);
return rlist;
}
rlist.add(1);
rlist.add(1);
// if(rowIndex==1)return rlist;
// else if(rowIndex==2){
// rlist.add(1, 2);
// return rlist;
// }
//行
for(int i=1;i<rowIndex+1;i++){
temp.add(1);
temp.add(1);
//每行中的列
for(int j=1;j<i;j++){
// temp.add(rlist.get(j)+rlist.get(j-1));
temp.add(j, rlist.get(j)+rlist.get(j-1));
}
rlist = temp;
temp = new ArrayList<Integer>();
}
return rlist;
}
需要频繁插入,删除要使用List!!