Using some maths, and the knowlede that kth row of Pascal’s traingle is basically kCr, r ranging from 0 to k:

vector Solution::getRow(int A) {

vector result;

long long int nume=1,deno=1;

int top=A+1,bottom=0;

result.push_back(1);

if(A==1)

{

result.push_back(1); //1st row is 1 1 according to the test case here, not just 1. May be a mistake.

return result;

}

//Since factorials can be large, used a different way of generating nCr without doing the whoel factorials, multiplying only as much as is needed

//The maths is just for counting differently in terms on even and odd. Dont sweat too much over it, you can probably formulate it easier

for(int i=1;i<=(A+1)/2-(A%2==0?0:1);i++)

{

nume*=(top-1);

deno*=(bottom+1);

result.push_back(nume/deno);

top–;bottom++;

}

int size=result.size()-1;

//Mirroring the other half now, taking care of even and odd cases

for(int i=(size-(A%2==0?1:0));i>=0;i–)

result.push_back(result[i]);

return result;

}