Problem Statement:
A clothing company wants to start a new line of clothing made from recycled clothes. The company wants this line to consist only of words formed from letters 'a' to 'z'. The creative team is facing challenges as they need to use a similar patch multiple times to achieve the desired design. To address this, the product team needs to find the sequence in which they should use the patch to get the desired words on the clothing.
Input:
The first line consists of a string patch, representing the patch.
The second line consists of a string designerWords, representing the words to be printed on the clothing.
Output: Print N space-separated integers indicating the sequence in which the patch should be used to obtain the desired words. If there is no possible way, then print -1.
Note: If multiple possible sequences exist, print the smallest permutation.
Example:
Input:
ab
aab
Output:
0 1
Explanation:
The patch needs to be used in the following way to create the desired word:
Place the first patch at index 0 to get "ab".
Place the second patch at index 1 to form "aab".
The requirement states that the second patch 'b' of the first patch overlaps with 'a' of the second patch.
Input:
yz
yzzz
Output:
2 1 0
i have a greedy approach for this but how to get the smallest permutation ?