1055. Shortest Way to Form String

You are given two strings, reference and target. In one pass, you scan reference from left to right and take a subsequence of its characters. Return the minimum number of passes needed to form target by concatenating the subsequences taken in each pass. If target contains a character that does not appear in reference, return -1.

Examples
Input: ["abc","abcbc"]
Output: 2
Hints
Related Problems

1055. Shortest Way to Form String

You are given two strings, `reference` and `target`. In one pass, you scan `reference` from left to right and take a subsequence of its characters. Return the minimum number of passes needed to form `target` by concatenating the subsequences taken in each pass. If `target` contains a character that does not appear in `reference`, return `-1`.