You are viewing a single comment's thread. Return to all comments →
Solution in Haskell with memoization
bst :: Int -> Integer bst = (map f [0..] !!) where f 0 = 1 f 1 = 1 f n = sum [ bst (i-1) * bst (n-i) | i <- [1..n]] `mod` (10^8 + 7) main :: IO() main = do raw <- getContents mapM_ print $ map bst $ tail $ map (read :: String -> Int) $ lines raw
Seems like cookies are disabled on this browser, please enable them to open this website
Number of Binary Search Tree
You are viewing a single comment's thread. Return to all comments →
Solution in Haskell with memoization