We give a polynomial-time dynamic programming algorithm for solving the linear complementarity problem with tridiagonal or, more generally, Hessenberg P-matrices. We briefly review three known tractable matrix classes and show that none of them contains all tridiagonal P-matrices.