Google-Developer-Student-Club-CCOEW / Competitive-Programming-2023-GDSC-CUMMINS-X-GDSC-MMCOE

Welcome to the Hacktoberfest 2023 Competitive-Programming Cohort for Cummins College and MMCOE students! To request issue assignment, create a pull request, providing: 1. Full Name 🧑‍🎓 2.Email 📧 3.College ID (RNO) 🔢 4.Branch of Study.📚 5. Year 📆 .The Cummins College and MMCOE students' PRs will be considered only. Thank you!
9 stars 69 forks source link

Merge Two Binary Trees #68

Closed soniadessai closed 1 year ago

soniadessai commented 1 year ago

Write code in the preferred language and attach output with it.

You are given two binary trees root1 and root2.

Imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge the two trees into a new binary tree. The merge rule is that if two nodes overlap, then sum node values up as the new value of the merged node. Otherwise, the NOT null node will be used as the node of the new tree.

Return the merged tree.

Note: The merging process must start from the root nodes of both trees.

Example 1:

image

Input: root1 = [1,3,2,5], root2 = [2,1,3,null,4,null,7] Output: [3,4,5,5,4,null,7]

Example 2:

Input: root1 = [1], root2 = [1,2] Output: [2,2]

Srush2823 commented 1 year ago

Can u please Assign me this issue Name-Srushti Johari C number-UCE2021429 srushti.johari@cumminscollege.in srush2823@gmail.com (github) TY Comp Cummins college of engineering pune