Description

You are given two strings stamp and target. Return an array of the index of the left-most letter being stamped at each turn. If the target is not achievable, return an empty array.

Examples

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

Stamp at index 0 then 2.

Input:stamp = "a", target = "a"
Output:[]
Explanation:

Edge case with a single character.

Input:stamp = "xy", target = "xyxy"
Output:[0,2]
Explanation:

Start with target "xyxy". First stamp "xy" at index 0, which matches positions 0-1. Then stamp "xy" at index 2, which matches positions 2-3. This covers the entire target string.

Constraints

  • 1 ≤ stamp.length ≤ target.length ≤ 1000

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!