Trains the technique from
LeetCode 387First Unique Character in a StringThis 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 courier's shift is written down as the string route. Each position holds one lowercase letter naming the loading bay that was visited at that point in the shift, and a bay can be visited more than once.
A bay is solo when it shows up exactly once in the whole shift. Return the position of the earliest solo bay in route, counting positions from 0. If every bay in the shift was visited two or more times, return -1.
Example 1
Bay s is visited three times, so the earliest bay visited once is w at position 1.
Example 2
Bays k and a are each visited twice, leaving y at position 2 as the only solo bay.
Example 3
The single bay in this shift is visited twice, so no solo bay exists.
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 first_solo_stop(route: str) -> int:public int firstSoloStop(String route)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.