Shortest Way to Form String
Input:
source =
"abc"
, target =
"abcbc"
Output:
2
Explanation:
The target "abcbc" can be formed by "abc" and "bc", which are subsequences of source "abc".Input:
source =
"abc"
, target =
"acdbc"
Output:
-1
Explanation:
The target string cannot be constructed from the subsequences of source string due to the character "d" in target string.Last updated