GeeksforGeeks » Interview Questions

NVIDIA Interview Question for Software Engineer/Developer

(2 posts)
  1. don
    guest
    Posted 9 months ago #

    rotate a 2D matrix by angle 180

  2. 112358
    guest
    Posted 4 months ago #

    MATRIX[MAX_ROW][MAX_COL];
    for(i=0; i<MAX_ROW/2; i++)
        for(j=0;j<MAX_COL; j++)
            swap(MATRIX[i,j], MATRIX[MAX_ROW-1-i][MAX_COL-1-j]);
    if(MAX_ROW%2!=0)
    {
        for(j=0; j<MAX_COL; j++)    // i would have already gone to the middle row when above loop quit
            swap(MATRIX[i,j], MATRIX[MAX_ROW-1-i][MAX_COL-1-j]);
    }
     

Reply

You must log in to post.

RSS feed for this topic