LeetCode 1337. The K Weakest Rows in a Matrix in F#
URL
leetcode.com/problems/the-k-weakest-rows-in..
Code
github.com/syohex/dotnet-study/blob/master/..
let kWeakestRows (mat: int list list) (k: int) : int list =
mat
|> List.mapi (fun i v ->
let count = v |> List.reduce (+)
i, count)
|> List.sortWith (fun (i, a) (j, b) ->
if a <> b then
compare a b
else
compare i j)
|> List.take k
|> List.map fst