I see the code in the forum, but how to come up with such an idea? What is the motivation behind this?

  • -2

    class Solution {
    vector<int> getRow(int rowIndex) {
    vector<int> A(rowIndex+1, 0);
    A[0] = 1;
    for(int i=1; i<rowIndex+1; i++)
    for(int j=i; j>=1; j--)
    A[j] += A[j-1];
    return A;

Log in to reply

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