2019-03-11から1日間の記事一覧
問題 Given the root to a binary tree, implement serialize(root), which serializes the tree into a string, and deserialize(s), which deserializes the string back into the tree. 実装 再帰的に実装します。Noneでなければ展開するようにしています…
内容 lispで使うcar, cdrをpythonで実装してみました。 def cons(a, b): def pair(f): return f(a, b) return pair def car(pair): def f(a, b): return a return pair(f) def cdr(pair): def f(a, b): return b return pair(f) if __name__ == "__main__": …