[LeetCode]杨辉三角 II

版权声明:本文为本人原创文章,未经博主允许不得转载。 https://blog.csdn.net/m0_37316917/article/details/87889123

题目

 

代码 

class Solution {
public:
    vector<int> getRow(int rowIndex) {
        vector<int> array(rowIndex+1);
        for(int i=0;i<=rowIndex;i++){
          for (int j = i - 1; j > 0; j--){ 
              array[j] = array[j - 1] + array[j];
          }
          array[i]=1;

        }
        return array;

    }
};

猜你喜欢

转载自blog.csdn.net/m0_37316917/article/details/87889123