Very Easy and Simple Code ... Whole code in no more than 5 line


vector Solution::getRow(int A) {
vector arr={1};
for(int i=0;i<A;i++)
return arr;


what does this statement do?
vector arr={1};
and whats the logic used in the code?


it is equivalent to
vector arr;
the first element is initialised to 1
elegent solution by the way
please and thank you


concept of nCr and nCr+1 is used here as elements of the kth row would be [1,nC1,nC2,nC3,…nCr,nCr+1,…1]. and nCr+1=nCr*(n-r)/(r+1). therefore every next element of the row can easily be found by the previous element with the help of this formula.I hope its clear :slight_smile: