A simple and easy to understandable approach


#1

vector<vector > Solution::diagonal(vector<vector > &A) {
int n = A.size();
int x = (2*n) - 1;
vector<vector> ans(x);
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
ans[i+j].push_back(A[i][j]);
}
}
return ans;
}