Very simple 10 line solution


#1

vector<vector > Solution::diagonal(vector<vector > &A) {
vector<vector> v1;
map<int,vector> m1;
for(int i=0;i<A.size();i++){
for(int j=0;j<A[i].size();j++){
m1[i+j].push_back(A[i][j]);
}
}
for(auto it=m1.begin();it!=m1.end();it++){
v1.push_back(it->second);
}
return v1;
}