Simple and Intutive C++ solution


#1
 vector<vector<int> > Solution::diagonal(vector<vector<int> > &A) {
       vector<vector<int> >  ans;
       vector <int> temp;
       int n = A.size();
       int m = A[0].size();
   
       int i =0 , j =0;
       int k = 0 , l =0;

      while(i < n && j < m){
             temp.clear();
             while(j>=0 && i <n){
                 temp.push_back(A[i][j]);
                 j--;
                 i++;
            }
            ans.push_back(temp);
            if(l == m-1){
                 k++;
            }else{
                 l++;
            }
                 j =l;
                 i = k;

     }


return ans;