Topic notebook / 02
Strings & windows
A moving window represents a contiguous section. Extend it to discover new values and shrink it when a rule is broken.
What to look for
- Define what makes the window valid.
- Keep both pointers moving forward.
- Update the answer only for a valid window.
Work through a question
10 availableFind a Clean Signal
A receiver records lowercase letter codes. Return the longest continuous segment with no repeated code, not just its length. If segments tie, return the earliest one.
Medium / Sliding window / interactiveFit a Letter-Budget Banner
A sign maker can stock at most k distinct lowercase letter stamps. Return the longest continuous piece of a message that fits that budget. Repeated letters are allowed. If lengths tie, keep the earliest piece.
Medium / Frequency-count sliding window / interactiveFind the Smallest Supply Label
A lowercase label must contain every requested letter, including repeated requests. Return its shortest continuous piece that covers the request. Ties keep the earliest piece; no covering piece returns "".
Hard / Minimum covering window / interactiveFind the Longest Mirror Message
Return the longest continuous piece of a lowercase message that reads the same forward and backward. Ties keep the earliest piece.
Medium / Expand around centers / interactiveRepaint a Signal Run
A beacon log uses uppercase ASCII letters. Repaint at most k positions so one continuous run has a single letter. Return the largest run length, not the repainted text. Empty logs return 0.
Medium / Frequency sliding window / interactiveCompare Letter Inventories
Two lowercase ASCII crate labels are interchangeable when their letter inventories agree, including repeated letters. Given a JSON object with left and right strings, return an explicit boolean.
Easy / Frequency balance / interactiveBundle Rearrangeable Labels
Bundle lowercase ASCII labels with identical letter inventories. Preserve duplicates. Sort each bundle alphabetically, then sort the bundles lexicographically so the returned JSON is deterministic.
Medium / Canonical signature map / interactiveCheck a Mirror Stamp
A stamp may contain printable ASCII text. Ignore everything except ASCII letters and digits, compare letters without case, and return whether the remaining sequence reads equally in both directions.
Easy / Two pointers with skipping / interactiveCount Mirror Fragments
Count every nonempty palindromic slice of a lowercase ASCII message. Different positions count separately even when their text is identical. Return a number, not distinct fragment texts.
Medium / Odd and even center expansion / interactivePack Labels Without Escaping
Given a JSON list of ASCII strings (including empty strings and # marks), return {"encoded": string, "decoded": list}. Frame each label as decimal character length, #, then exactly that many characters. Decode your own encoding and preserve every label.
Medium / Length-prefixed framing / interactiveWhere this leads
Return to the roadmap to try a different kind of problem.