import Foundation

class BinaryTreeNode {
    let value: Int
    var left: BinaryTreeNode?
    var right: BinaryTreeNode?
    init(_ value: Int) {
        self.value = value
    }
}
struct BinaryTree {
    var root: BinaryTreeNode?

    func height(_ node: BinaryTreeNode?) -> Int {
        guard let node = node else { return 0 }
        let leftHeight = height(node.left) + 1
        let rightHeight = height(node.right) + 1
        return leftHeight > rightHeight ? leftHeight : rightHeight
    }
}