Get Patch Sequence
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.
Complete the function getPatchSequence in the editor.
getPatchSequence has the following parameters:
- 1.
String patch: a string representing the patch - 2.
String designerWords: a string representing the words to be printed
Returns
int[]: an array of integers indicating the sequence in which the patch should be used, or an array with a single element -1 if it's not possible