solution to hasPathSum