Let's say we have given array $A$ of size $n$. Our goal is to delete the whole array with minimum steps. In one step we can choose substring (consecutive elements from the string) and delete it only if it is a palindrome (if we can read it in the same way from the front and the back).
For example the array 1 1 5 9 5 1 can be deleted in two steps. Step 1: Delete substring 5, 9, 5. Then delete the remaining substring 1, 1, 1. We only need to return 2, the number of steps.
My idea is to use dynamic programming technique. Our state would be $DP[L][R]$ meaning the minimum number of steps to delete the substring in range $[L, R]$. However I can't really work the transitions, since there can be cases when our front element will merge with some element in the middle and with some elements in the back, so I don't know how to cover all transitions between different states.