Minimal and characteristic polynomial question $$A =\left(\begin{array}{rrrr}
0 & 1 & -1 & 1\\
-1 & 2 & -1 & 1\\
0 & 0 & 1 & -1\\
0 & 0 & 0 & 0
\end{array}\right).$$
We have this matrix, we want to find the characteristic and the minimal polynomial.
I have done the following:
First I used the formula $\det(A -\lambda I) = 0$, then I got this determinant into upper triangular form by getting rid of the $-1$ in the second row. Then I multiplied the diagonal and got :
$$(\lambda +1+ \sqrt{2})(\lambda + 1- \sqrt{2})(1-\lambda)(-\lambda) = 0 = p(\lambda)$$
Wolfram alpha gives the same result.
However the solution says that the characteristic and minimal polynomial should be
$$p_A(\lambda) = \lambda(\lambda-1)^3,\quad m_A(\lambda) = \lambda(\lambda -1)^2.$$
I do not understand how they got there or where is the mistake in my process.

If you compute the determinant of $A-\lambda I$ outright you should get:
$$\begin{align*}
\det\begin{bmatrix}
-\lambda & 1 & -1& 1\\
-1 & 2-\lambda & -1 & 1\\
0&0 & 1-\lambda & -1 \\
0&0&0& -\lambda
\end{bmatrix} &= 
-\lambda \det\begin{bmatrix}-\lambda & 1 & -1\\ -1 & 2-\lambda & -1 \\ 0 & 0 & 1-\lambda \end{bmatrix}\\
 &= -\lambda(1-\lambda) \det\begin{bmatrix} -\lambda & 1\\ -1 & 2-\lambda\end{bmatrix}
\end{align*}$$
by cofactor expansion along the bottom rows. The last term is:
$$
-\lambda(1-\lambda)[\lambda^2-2\lambda +1] = \lambda(\lambda -1)[(\lambda-1)^2] = \lambda(\lambda -1)^3.
$$ From here, you know that the minimal polynomial is one of $\lambda (\lambda -1), \lambda (\lambda -1)^2, \lambda (\lambda -1)^3$ since it must share the same roots as the characteristic polynomial. Since there are only three you can plug in and check.
