Subodh

Limits: 3s, 128 MB

Subodh is going to paint a very big wall. The wall is composed of N adjacent parts in line. He wants to paint each part with a particular color. He paints in a somewhat peculiar mechanism. At each step he chooses some consecutive parts of the wall and paints them with same color. Initially, there is no color on any part of the wall. You’re given the target color for each part of the wall. You have to tell the minimum number of steps Subodh will require if he wants to paint the whole wall in the desired color combination using his peculiar approach.


This is a companion discussion topic for the original entry at https://toph.co/p/subodh