您的位置:首页 > 其它

119 Pascal's Triangle

2015-05-29 07:16 435 查看
public class Solution {
public ArrayList<Integer> getRow(int rowIndex) {
ArrayList<Integer> res = new ArrayList<Integer>();
if (rowIndex < 0) {
return res;
}

res.add(1);
for (int i = 1; i <= rowIndex; i++) {
for (int j = res.size() - 2; j >= 0; j--) {
res.set(j+1, res.get(j) + res.get(j + 1));
}
res.add(1);
}
return res;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: