text: /**
   * Definition for a binary tree node.
   * struct TreeNode {
   *     int val;
   *     TreeNode *left;
   *     TreeNode *right;
   *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
   * };
   */
  class Solution {
  public:
      TreeNode* mergeTrees(TreeNode* t1, TreeNode* t2) {
          if (t1 == nullptr && t2 == nullptr) {
              return nullptr;
          }
  
          TreeNode* newNode = new TreeNode(0);
  
          if (t1 != nullptr) {
              newNode->val += t1->val;
          } 
  
          if (t2 != nullptr) {
              newNode->val += t2->val;
          }
  
          newNode->left = mergeTrees(t1 == nullptr ? nullptr : t1->left, 
              t2 == nullptr ? nullptr : t2->left);
          newNode->right = mergeTrees(t1 == nullptr ? nullptr : t1->right, 
              t2 == nullptr ? nullptr : t2->right);
  
          return newNode;
      }
  
  };