欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

119. Pascal's Triangle II

程序员文章站 2022-04-01 12:12:48
...

119. Pascal's Triangle II
119. Pascal's Triangle II

    vector<int> getRow(int rowIndex) {        
        vector<int> res;
        if(rowIndex<0) return res;
        res.assign(rowIndex+1,0);
        for(int i=0;i<=rowIndex;i++){
            if(i==0)
            {
                 res[i]=1;
                continue;
            }
            for(int j=rowIndex;j>0;j--){
                res[j]+=res[j-1];
            }
        }  
        return res;
    }

119. Pascal's Triangle II