GeeksforGeeks » Interview Questions
NVIDIA Interview Question for Software Engineer/Developer
(2 posts)-
rotate a 2D matrix by angle 180
-
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.