loading...

re: Daily Coding Problem #2 VIEW POST

FULL DISCUSSION
 

O(n) time, using division, in haskell:

f :: [Int] -> [Int]
f xs = let p = product xs in map (p `quot`) xs

O(n) time, without division, in haskell:

f :: [Int] -> [Int]
f xs = zipWith (*) l r
  where
    l = init $ scanl (*) 1 xs
    r = tail $ scanr (*) 1 xs
Code of Conduct Report abuse