What edge cases am I missing in my solution - WA MINOPS


  • 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?

Try this testcase:
O/P should be 19.

And do check for identical strings, completely different strings, and strings of size 1.