Trains the technique from
LeetCode 438Find All Anagrams 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 tiler is repairing a mosaic border. The finished border is written down as border, one lowercase letter per tile in the order the tiles run left to right, each letter standing for a colour. A sealed box of spare tiles is written down the same way as bundle.
The tiler wants to know where a single box could have supplied a run of the border. A box supplies the run starting at position i when that run is exactly as long as the box and holds the same colours in the same quantities, in whatever order they happen to be laid. Quantities matter: a box holding two red tiles cannot supply a run holding one red tile and two blue ones.
Return the starting positions of every run the box could supply, listed from smallest position to largest. Return an empty list when there is no such run, which includes the case of a box holding more tiles than the whole border.
Example 1
The runs beginning at 0, 3 and 4 each hold one t, one s and one r. The run beginning at 4 reaches the end of the border, so the last run counts as well.
Example 2
The box holds two r tiles and one s. The run beginning at 0 draws on the same two colours but in the wrong quantities, so only the runs at 2 and 3 qualify.
Example 3
The box holds three tiles and the border only has two, so no run can be as long as the box.
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 bundle_positions(border: str, bundle: str) -> list[int]:public List<Integer> bundlePositions(String border, String bundle)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.