Clone a binary tree. Node<T> cloneTree<T>(Node<T> n) { if (n == null) return null; Node<T> c = new Node<T>(n.val); c.left = cloneTree<T>(n.left); c.right = cloneTree<T>(n.right); return c; } |
Trees and Graphs >
Trees and Graphs >
Clone Tree
|