LeetCode Entry
867. Transpose Matrix
Transpose 2D matrix
867. Transpose Matrix easy
blog post
substack
youtube

Join me on Telegram
https://t.me/leetcode_daily_unstoppable/434
Problem TLDR
Transpose 2D matrix
Complexity
-
Time complexity: \(O(n)\)
-
Space complexity: \(O(n)\)
Code
fun transpose(matrix: Array<IntArray>): Array<IntArray> =
Array(matrix[0].size) { x ->
IntArray(matrix.size) { y ->
matrix[y][x]
}
}