convex recoloring of string using brute force dynamic programming