pathSum reimpl