Solution to maximum path sum problem I & II