Special String Again

  • + 2 comments

    Why this approach return 11 for input 'cbbabbc' as an example ?

    Correct answer should be 12 in this case. (c, b, b, a, b, b, c, bb, bb, bab, bbabb, cbbabbc)

    I think there is a bug in 3rd testCase as its only checking i-1, i and i+1.

    There should be a recursive way to keep check n-1 and n+1 terms until they are matching or something like that, then start taking min of each of those.