input already given, output should be 15 rather than 13…
Getting wrong output for above implementation
Hi @Akshay123
refer to dis updated code.
in this i have changed and added this
int res=max(cand1,max(cand2,max(cand3,cand4)));
global_max=max(global_max,res);
the res integer is declared for accessing max value from childrens
global value stores the max for whole tree.
Hope dis helps.
If still something is not clear, feel free to post
whats the use of globAL_max variable
@Akshay123,
global max stores the max value in the whole tree. as u mentioned, what if root was negative, global max will store whats the biggest cost in left or right subtree.
Hope dis helps.