modify maxPathSum.java to a neater solution