\documentclass{article}
\usepackage[ruled,vlined]{algorithm2e}
 
\begin{document}
\begin{algorithm}[H]
\SetAlgoLined
\KwResult{rexp }
 Compute list $l_1: [r_1\backslash c_1 \cdots c_n, r_1\backslash c_1 \cdots c_{n-1}, ..., r_1 \backslash c_1, r_1]$\;
 Compute list $l_2: [r_2, r_2\backslash c_n, r_2\backslash c_{n-1} c_{n}, ..., r_2 \backslash c_1\cdots c_n]$\;
 Compute list $l_3$: 
 $l_3 \gets []$ \;
 \For{$i\gets1$ \KwTo $n$}{
    $\mathit{if} \; \mathit{nullable}(r_1 \backslash c_1 \cdots c_{n-i+1}) \; \mathit{then} \; \mathit{add} \; i \; \mathit{to} \; l_3$
    }
    $result \gets r_1 \backslash c_1 \cdots c_n \cdot r_2$\\
 \For{$i\gets0$ \KwTo $l_3.length -1$}{
 $result \gets \mathit{ALT}(result, l2[l3[i]])$
 }
 \Return result
 \caption{ders2forSEQ($r_1$,$r_2$,$s$)}
\end{algorithm}
\end{document}