Approach:
- Store indexes of non-matching characters in an array (increasing order)
- Iterate above array from N-1 to 0 index where N is the size of the array
- On every iteration compute the cost,
- where currcost = ((arr[i] - arr[0] + 1) + size(arr[i+1…N-1])) * (N - arr[i])
- Take the min of prevcost and currcost
Code : 32083748
What did I miss?