Live long and prosper
Find out the maximum cost of all the possible root-to-leaf paths
123456789101112
public class solution{ public int maxPathCost(Node root){ if (root == null) return 0; if (root.left == null && root.right == null) return root.value; int leftMax = maxPathCost(root.left); int rightMax = maxPathCost(root.right); return root.val + leftMax > rightMax ? leftMax : rightMax; }}