You are given a square 2D image matrix where each integer represents a pixel. Write a method **Transpose** - **in-place**.

**Example:**Input image :

1 0

1 0

Modified to :

1 1

0 0

`transposeMatrix`

to transform the matrix into its 1 0

1 0

Modified to :

1 1

0 0

Need a **hand?** Try out these hints, one at a time.

Remember that if you modify an input parameter that is of type Array in Java, you're actually modifying the object itself! That's why the return type is void.

Remember this pattern for all 2D array problems :

`int rows = matrix.length`

and `int columns = matrix[0].length`

. Once you have the row / column dimensions (in this case, the same), write 2 for loops that traverse the top half of the square matrix. In the inner for loop, use a temporary variable to make the swap. temp = matrix[i][

matrix[i][j] = matrix[j][

matrix[j][i] = temp;

public static void transposeMatrix(int[][] matrix) { }

**C**

**Java**

**Python**