Konstante
Senior Member
Viết bằng F# thì test kiểu gì nhỉ? Vì leetcode không hỗ trợ F#.Naive solution, F#
Mã:// Defines the signature for the `cook`-function, // although this is not strictly necessary // thanks to the powerful type-inference system in F# type Cook = string list -> string list list -> string list -> string list let rec cook: Cook = fun recipes ingredientSets supplies -> let recipes = List.zip recipes ingredientSets let canCook = List.except supplies >> List.isEmpty let completed, pending = recipes |> List.partition (snd >> canCook) match completed with | [] -> [] | completed -> let completed = completed |> List.map fst match pending with | [] -> completed | pending -> let newRecipes, newIngredients = pending |> List.unzip let newSupplies = completed |> List.append supplies cook newRecipes newIngredients newSupplies |> List.append completed
Mấy cái CP thì chỉ có kattis là hỗ trợ F#, trước đây toàn bộ solution submit lên đó mình viết bằng F#



, chỗ build tree kia xem lại tiếp nha
add thẳng cái cục ingredients luôn sao phải init, loops rồi add nhìn hơi mệt.


