Help me ,tell me where i made mistake


#1

vector<vector > Solution::solve(int A) {
vector<vector>res;
int v=0;
for(int i=0;i<A;i++){
for(int j=0;j<=i;j++){
if(j==0||j==i)
res[i].push_back(1);
else
v=res[i-1][j-1]+res[i-1][j];
res[i].push_back(v);

    }
}
return res;

}


#2

Define vector size like
vector<vector> a(n);
If you don’t define the size than you can’t acces like this a[i] .