diff --git a/Lecture 10 : Trees/Node having sum of children and node is max.java b/Lecture 10 : Trees/Node having sum of children and node is max.java index 8295f35..4ec094f 100644 --- a/Lecture 10 : Trees/Node having sum of children and node is max.java +++ b/Lecture 10 : Trees/Node having sum of children and node is max.java @@ -32,7 +32,28 @@ public class Solution { public static TreeNode maxSumNode(TreeNode root){ - // Write your code here + if(root == null) + return null; + TreeNode temp=null; + Queue> q=new LinkedList<>(); + q.add(root); + int s=0; + while(!q.isEmpty()){ + int size=q.size(); + for(int i=0;itemp1=q.poll(); + int s1=temp1.data; + for(int j=0;js){ + s=s1; + temp=temp1; + } + } + } + return temp; }