Simple vector sol: segmentation fault


#1

vector Solution::getRow(int A) {
vector<vector> vec(2);
// if(A==0)return vec[0];

for(int i=0; i<=A; i++)
{
    vec[(i%2)]=vector<int> (i+1);
    
    for(int j=0; j<(i+1); j++)
    {
        if((j==0)||(i==j))vec[i][j]=1;
        else
        vec[(i)%2][j]=vec[(i+1)%2][j-1]+vec[(i+1)%2][j];
    }
}
if((A%2)==0)return vec[0];
else return vec[1];

}