cutsDp
with cutsDp[i]
representing the minimum cuts needed for the substring s[0...i]
.\n2. Set cutsDp[i]
to i
for all i
, since the maximum cuts needed is i
(cutting between each character).\n3. Iterate over the string with index mid
from 0
to n-1
, considering both odd and even length palindromes.\n4. For each mid
, expand around the center to find the longest palindrome and update cutsDp
using the formula cutsDp[end] = min(cutsDp[end], 1 + cutsDp[start - 1])
.\n5. After the loop, return cutsDp[n - 1]
as the minimum number of cuts needed for the entire string.