LeetCode 867. Transpose Matrix in F#
URL
leetcode.com/problems/transpose-matrix
Code
github.com/syohex/dotnet-study/blob/master/..
let transpose (matrix: int [,]) : int [,] =
let rows = Array2D.length1 matrix
let cols = Array2D.length2 matrix
let ret = Array2D.zeroCreate cols rows
for i in 0 .. (rows - 1) do
for j in 0 .. (cols - 1) do
ret.[j, i] <- matrix.[i, j]
ret