10.12.2023
867. Transpose Matrix easy
blog post
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]
}
}