Abstract.A new algorithmic setting is proposed for the discrete-time finite-horizon linear quadratic (LQ) optimal control problem with constrained or unconstrained final state, no matter whether the problem is cheap, singular, or regular. The proposed solution, based on matrix pseudoinversion, is completed and made practically implementable by a nesting procedure for welding optimal subarcs that enables arbitrary enlargement of the control time interval. [17,18,4,22], and Soethoudt, Trentelman and Ran in [21,16]. Extension to cheap and singular problems is obtained by using matrix pencils or linear matrix inequalities.The above contributions mainly refer to continuous-or discrete-time infinitehorizon LQR problems. Conversely, this work focuses on the finite-horizon case for discrete-time systems. It applies to cheap, singular, or regular problems. Considering a sharp constraint on the final state, this paper extends the results given in [16], where the infinite-horizon case with asymptotic endpoint constraints is investigated. However, in the present paper, the requirement that the cost functions are positive semidefinite is still present, while in [16] it is not.From the algorithmic viewpoint, the present work differs from those of the abovementioned papers and is inspired by the system structure algorithm introduced by Silverman in his well-known contribution [20]; see also [19,8]. In the present work, the solution is achieved by the straightforward technique of pseudoinverting a particular system matrix as in [20], but the time interval considered can be arbitrarily