in place transpose in a matrix in java

Solutions on MaxInterview for in place transpose in a matrix in java by the best coders in the world

showing results for - "in place transpose in a matrix in java"
Wayne
22 Jan 2020
1  //Transpose a Matrix
2
3  for (int row = 0; row < matrix.length; row++) {
4    
5   for (int col = row; row < matrix[row].length; col++) 
6   {
7    	// Swap 
8     	int data = matrix[row][col];
9    	matrix[row][col] = matrix[col][row];
10   		matrix[col][row] = data;
11   }
12  
13  }