Beautiful problem on Dynamic programming.
Problem Statement Given a string we can select any substring consisting of all equal characters and remove it and this will be counted as one step.you need to find minimum number of steps to remove the string completely. Now a greedy approach can be deleting the largest substring consisting of equal characters,although it seems accurate but it will easily fail. Consider string "aaabaa" so greedy will delete "aaa" first in one step,then "aa" in second step and finally "b" in third step giving total of 3 steps but optimal is deleting "b" in one step and "aaaaa" in second step giving 2 steps. So either the string at current index will be removed individually or will be paired with some other character at index greater than current index which is equal to it. Let the string be str[low...high] where low=0,high=n-1 and n is length of str. Let our recursive function be func(low,high) So the recursive function will be called in 2 st...