Given a string s0 find the lexicographically smallest palindrome of the same length that is lexicographically greater than or equal to
Strings may contain only lowercase English letters.
s0 = "cbaba", the output should be
smallestPalindrome(s0) = "cbabc";
s0 = "abcbc", the output should be
smallestPalindrome(s0) = "abdba".
- [time limit] 4000ms (js)
- [input] string s0
A string containing only lowercase English letters.
4 ≤ s0.length ≤ 5 · 10^5.
The required palindrome.
Help me define steps in solving this algorithm I can’t recognize the pattern, so I am not sure what to do. Any clues will be helpful, I understand what is lexicographically smallest palindrome. What I don’t understand is the logic behind generating new palindrome, when can I introduce a new letter that hasn’t been part of input?