path sum implementation