This question evaluates proficiency in string algorithms and linked list manipulation, specifically techniques for constructing the shortest palindrome by prepending characters and reordering singly linked lists by 1-based index parity.
You are asked to solve two coding problems.
s
, add characters only to the
front
of the string so that the final string is a palindrome. Return the shortest possible result. Aim for a solution better than checking every prefix naively.
For both problems, explain the algorithm and analyze time and space complexity.