Simple C++ code easy to understand


  • -1
    D

    vector<int> getRow(int rowIndex) {
    vector<int> row;
    if(rowIndex<0) return row;
    row.push_back(1);
    int x = ceil((float)(rowIndex+1)/(float)2);
    long long int k=2;
    long long int p=rowIndex;
    long long int r=rowIndex;
    for(int i=1;i<=rowIndex;i++){
    row.push_back(p);
    p*=(r-1);
    p/=k;
    k++;
    r--;
    }
    return row;
    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.