Trains the technique from
LeetCode 680Valid Palindrome IIThis 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 mosaic studio finishes decorative border strips before they ship. A strip arrives as the string strip, one lowercase letter per tile naming that tile's glaze, listed from the left end of the strip to the right end.
The studio accepts a strip when it shows the same glaze sequence read from either end, and the finisher is allowed to pull out at most one tile first. Pulling a tile out closes the gap, so the two tiles that flanked it become neighbours. Pulling nothing out is also allowed, so a strip that already matches end to end is accepted as it stands.
Return true when the strip can be accepted and false when no single removal is enough.
Example 1
Pull the trailing `s` and the remaining six-tile run `level` shows the same glazes from either end.
Example 2
Dropping the `c` still leaves `obalt` mismatched at its ends, and dropping the `t` leaves `cobal` mismatched too, so one removal cannot rescue it.
Example 3
The strip already matches end to end, and removing nothing is permitted.
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 inspect_border(strip: str) -> bool:public boolean inspectBorder(String strip)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.