On constructing least squares solutions to two-point boundary value problems