杨辉三角 II ,给定一个非负索引 k,其中 k ≤ 33,返回杨辉三角的第 k 行

For example, given k = 3,
Return[1,3,3,1].

class solution{
public:
        vectorgetRow(int rowIndex) {
            vectorres(rowIndex+1,0);
            res[0]=1;
            for(int i=1;i<=rowIndex;i++)
            {
                for(int j=i;j>0;j--)
                {
                    res[j]=res[j]+res[j-1];
                }
            }
            return res;
    }
};

 

你可能感兴趣的:(LeetCode杨辉三角)