n to the length of s.sReverse as the reverse of s.dp and dpPrev of size n + 1 with zeros.s and sReverse using two nested loops.(i, j), check if s[i - 1] == sReverse[j - 1].dp[j] = 1 + dpPrev[j - 1].dp[j] = max(dpPrev[j], dp[j - 1]).dp to dpPrev.dp[n].n - dp[n] as the minimum number of insertions.