Using 2 vector esy to understand


#1
vector<int> prev, next;
if(n==0)
{
    prev.push_back(1);
    return prev;
}
if(n==1)
{
 next.push_back(1);next.push_back(1);
  return next;    
}
    next.push_back(1);next.push_back(1);
for(int i =2;i<=n;i++)
{
    prev.push_back(1);
    for(int j=0;j<next.size()-1;j++)
    {
        prev.push_back(next[j]+next[j+1]);
    }
    prev.push_back(1);
    next=prev;
    prev.clear();
}
return next;