https://oj.leetcode.com/problems/pascals-triangle-ii/
类似DP的迭代方法,只需注意数组大小分配即可。
class Solution {public: int n,m; vector c[2]; vector getRow(int rowIndex) { n=rowIndex; c[0].resize(n+1,0); c[1].resize(n+1,0); c[0][0]=1; for (int i=1;i<=n;i++){ int cur=i%2; int prev=(i-1)%2; c[cur][0]=1; c[cur][i]=1; for (int j=1;j