Trains the technique from
LeetCode 5Longest Palindromic SubstringThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A firmware pipeline stamps every build artifact with an alphanumeric label tag, made up only of digits and English letters.
Call a contiguous slice of tag a mirror run when the slice is identical to itself written back to front. Characters are compared exactly as they appear, so T and t never match.
Return the longest mirror run contained in tag. When two or more mirror runs are tied for longest, hand back the one whose first character sits at the lowest index.
Example 1
The slice `kayak` covers indices 0 through 4 and mirrors itself; `pop` also mirrors but is shorter.
Example 2
Here the widest mirror run has even width, sitting between the two `t` characters.
Example 3
Case matters, so the two characters do not mirror each other and the earliest single character wins.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def longest_mirror_run(tag: str) -> str:public String longestMirrorRun(String tag)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.