RamJane
BAN USER
Comments (3)
Follows (4)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
As per my understanding question is to replace the node with the sum of there left and right child .
above solution is good but we have to add in pace of
n.value = Math.max(leftValue, rightValue);
int temp=n.value;
n.value= leftValue+rightValu
return temp+n.value;
--------------------------------------------
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Hashtable+vector are good choice only in synchronized context.
- RamJane March 25, 2014Vector behind the scene is dynamic resizable array , so reduce by one is same as in array.
So it seems best approach is Hashmap+ doublyLinkedList.
hashmap can be used for deleting random o(1). and adding & removing is O(1) in list