Leetcode 119. 杨辉三角 II

C(n,0) C(n,1) C(n,2) ……C(n,n)

class Solution {
public:
    vector<int> getRow(int rowIndex) {
        vector<int> ans(1,1);
        for(int k=1;k<=rowIndex;++k) ans.push_back((long long)ans.back()*(rowIndex+1-k)/k);
        return ans;
    }
};
    原文作者:杨辉三角问题
    原文地址: https://blog.csdn.net/Bendaai/article/details/80601323
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞