您的位置:首页 > 其它

LeetCode-119.杨辉三角II(相关话题:数组)

2018-10-19 19:50 253 查看

Java代码:

[code]class Solution {
public List<Integer> getRow(int rowIndex) {
List<Integer> res = new ArrayList<>(rowIndex+1);
for(int i = 0; i <= rowIndex; i++){
res.add(1);
for(int j = i-1; j > 0; j--){
res.set(j, res.get(j) + res.get(j-1));
}
}

return res;
}
}
阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: