Update appNew update is available. Click here to update.
About
I am a very hardworking, enthusiastic, eager learner who always seeks challenges to override them with fun. I am able to handle multiple tasks on a daily basis and use a creative approach to problem s...
Inderprastha Engineering College 2023
My Stats
EXP gained
yellow-spark
2805
Level
5 (Champion)
Community stats
Discussions
1
Upvotes
0
Know more
87
Total problems solved
55
Easy
30
Moderate
2
Hard
0
Ninja
Jan Jan Feb Feb Mar Mar Apr Apr May May Jun Jun Jul Jul Aug Aug Sep Sep Oct Oct Nov Nov Dec Dec

Current streak:

0 days

Longest streak:

2 days

Less

More

Achievements
Discussions
Python direct solution o(N) time and space
Interview problems

from os import * from sys import * from collections import * from math import *

'''

   Following is the Binary Tree node structure        class BinaryTreeNode:        def __init__(self, data):            self.data = data            self.left = None            self.right = None

'''         def changeTree(root):     if root == None:        return    child = 0    if root.left!=None:        child+=root.left.data    if root.right !=None:        child+=root.right.data    if child>root.data:        root.data = child    else:        if root.left!=None:            root.left.data = root.data        if root.right!=None:            root.right.data = root.data    changeTree(root.left)    changeTree(root.right)    tot = 0    if root.left !=None:        tot+=root.left.data    if root.right !=None:        tot += root.right.data    if root.right!=None or root.left!=None:        root.data = tot    return    # Write your code here.    pass

profile
Muskan Maheshwari
Published On 29-Oct-2022
99 views
1 replies
0 upvotes
Python direct solution o(N) time and space
Interview problems

from os import * from sys import * from collections import * from math import *

'''

   Following is the Binary Tree node structure        class BinaryTreeNode:        def __init__(self, data):            self.data = data            self.left = None            self.right = None

'''         def changeTree(root):     if root == None:        return    child = 0    if root.left!=None:        child+=root.left.data    if root.right !=None:        child+=root.right.data    if child>root.data:        root.data = child    else:        if root.left!=None:            root.left.data = root.data        if root.right!=None:            root.right.data = root.data    changeTree(root.left)    changeTree(root.right)    tot = 0    if root.left !=None:        tot+=root.left.data    if root.right !=None:        tot += root.right.data    if root.right!=None or root.left!=None:        root.data = tot    return    # Write your code here.    pass

profile
Muskan Maheshwari
Published On 29-Oct-2022
99 views
1 replies
0 upvotes