As, we can observe here that for every index where i+j is same belongs to same new vector in output array. also, the size of output array is an AP, for which the general term is calculated as above.

So, here is simple code implementation for the same.

**Code:**

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