Tap here to switch tabs
Problem
Submissions

Problem: Shortest Way to Form String

med
30 min
Try to solve the Shortest Way to Form String problem.

Statement

Given two strings source and target, return the minimum number of subsequences of source that can be concatenated to form target. If it is impossible to construct target in this manner, return −1-1.

A subsequence of a string is a new string generated from the original string by deleting some or none of the characters without changing the relative order of the remaining characters.

Constraints:

  • 1≤1 \leq source.length, target.length ≤1000\leq 1000

  • source and target consist of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Shortest Way to Form String

med
30 min
Try to solve the Shortest Way to Form String problem.

Statement

Given two strings source and target, return the minimum number of subsequences of source that can be concatenated to form target. If it is impossible to construct target in this manner, return −1-1.

A subsequence of a string is a new string generated from the original string by deleting some or none of the characters without changing the relative order of the remaining characters.

Constraints:

  • 1≤1 \leq source.length, target.length ≤1000\leq 1000

  • source and target consist of lowercase English letters.