We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Highest Value Palindrome
You are viewing a single comment's thread. Return to all comments →
Hey guys,
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.