pyassistant

Minimum moves to clear array by removing palindromic contiguous subarrays

Given a list of integers arr, you may repeatedly remove any contiguous subarray that forms a palindrome in one move. After removal, the remaining parts concatenate and may form new palindromes. Compute the minimum number of moves required to remove the entire array.

Example:

Input:
([1, 2, 3, 2, 1, 4],)
Output:
2

Make sure you return your solution, don't print!

AI

Bot

Trying to solve my challenge? Ask if you must, or press the purple button so I can analyze your code.