Transpose of Matrix solution
Transpose of Matrix
Difficulty: EasyAccuracy: 66.5%Submissions: 118K+Points: 2Average Time: 20m
You are given a square matrix of size n x n. Your task is to find the transpose of the given matrix.
The transpose of a matrix is obtained by converting all the rows to columns and all the columns to rows.
Examples :
Input: mat[][] = [[1, 1, 1, 1],
[2, 2, 2, 2],
[3, 3, 3, 3],
[4, 4, 4, 4]] Output: [[1, 2, 3, 4],
[1, 2, 3, 4],
[1, 2, 3, 4],
[1, 2, 3, 4]] Explanation: Converting rows into columns and columns into rows.
Input: mat[][] = [[1, 2],
[9, -2]] Output: [[1, 9],
[2, -2]]
Explanation: Converting rows into columns and columns into rows.
Constraints:
1 ≤ n ≤ 103
-109 ≤ mat[i][j] ≤109
Comments
Post a Comment
Hi there,
I am ${NAME},
${Subject}
I would like to thank/suggest regarding this post.
${Description}
Please enter your description here[if willing to 😉].