What there is segmentation fault?


#1

Why there is segmentation fault in this code:

vector Solution::getRow(int A) {
A=A+1;
vector<vector >res(A);
for(int i=0;i<A;i++){
for(int j=0;j<=i;j++)
res[i].push_back(1);
}
for(int i=2;i<A;i++){
for(int j=1;j<i;j++){
res[i][j]=res[i-1][j]+res[i-1][j-1];
//cout<<res[i][j]<<endl;
}
}
return res[A];
}