You are viewing a single comment's thread. Return to all comments →
I just found an improvement which can be made to the editorial.
The solution in editorial doesn't cover the case that maximise the smallest palindrome element first. Apparently it maximises the value from left to right.
Try this edge case to see what I mean:
s = '81118'
k = 2
the highest value palindrome is 89198 with 2 changes. However the solution outputs 91119.