3315. Construct the Minimum Bitwise Array II in F#
URL
Construct the Minimum Bitwise Array II - LeetCode
Code
let minBitwiseArray (nums: int list) : int list =
let rec f n mask =
if n &&& mask = 0 then
n &&& ~~~(mask >>> 1)
else
f n (mask <<< 1)
nums |> List.map (fun n -> if n % 2 = 0 then -1 else f n 1)
Comments
Join the discussionNo comments yet. Be the first to comment.