Preview:
class Solution{
	public:
	vector<int> downwardDigonal(int n, vector<vector<int>> a)
	{
	    vector<int> v;
		for(int j=0;j<n;j++)
		{
		    int i=0,k=j;
		    while(i<n && k>=0)
		    {
		        v.push_back(a[i][k]);
		        i++;
		        k--;
		    }
		}
		for(int i=1;i<n;i++)
		{
		    int j=i,k=n-1;
		    while(j<n && k>=0)
		    {
		        v.push_back(a[j][k]);
		        j++;
		        k--;
		    }
		}
		return v;
	}
};
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter