Trains the technique from
LeetCode 3Longest Substring Without Repeating CharactersThis 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 lobby turnstile appends one character to a log string every time somebody taps a badge. That character is the person's short code, and codes are drawn from the full printable range: upper and lower case letters, digits, punctuation marks, and the space reserved for visitor passes. Codes are compared exactly, so K and k are two different people.
Security calls a block of back-to-back taps clean when no code shows up twice inside it. Given the log tape, return how many taps sit in the largest clean block. If nobody has tapped yet, report 0.
A block has to be an unbroken run of taps. You may not drop taps out of the middle of a block to keep it clean.
Example 1
The last four taps K, 7, Q and 9 are all different codes. Any block of five taps here picks up a second 7.
Example 2
The trailing pair QP is clean. Stretching it one tap to the left gives QQP, which repeats Q, so 2 is the ceiling.
Example 3
The visitor-pass space starts the winning block, which then runs Q, 7, ! and x for five distinct codes.
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 largest_clean_tap_block(tape: str) -> int:public int largestCleanTapBlock(String tape)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.