SHARE
TWEET

Untitled

a guest Jun 15th, 2019 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. func mergeTrees(node1: TreeNode?, node2: TreeNode?) -> TreeNode? {
  2.     if node1 == nil {
  3.         return node2
  4.     }
  5.    
  6.     if node2 != nil {
  7.         node1!.value += node2!.value
  8.         node1?.left = mergeTrees(node1: node1?.left, node2: node2?.left)
  9.         node1?.right = mergeTrees(node1: node1?.right, node2: node2?.right)
  10.     }
  11.     return node1
  12. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top