Skip to content

Practice Stamping The Sequence

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#936
LeetCode Problem

Stamping The Sequence

Problem Statement

Start with target.length question marks. Each turn places the entire stamp within the current string and overwrites that consecutive segment with stamp, possibly replacing earlier stamped characters. Return any list of starting indices that produces target in at most 10 * target.length turns, or an empty list if impossible. A stamp may not extend beyond either boundary.

Source: Stamping The Sequence on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
stamp = "abc", target = "ababc"
Output
[0,2]

# Example 2

Input
stamp = "abca", target = "aabcaca"
Output
[3,0,1]

Constraints

1 <= stamp.length <= target.length <= 1000
stamp and target consist of lowercase English letters.

Related LeetCode Problems

Practice more problems similar to Stamping The Sequence.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.