Tap here to switch tabs
Problem
Submissions

Problem: Shortest Way to Form String

Shortest Way to Form String gives source and target strings. Return the fewest subsequences of source that can be concatenated to form target, or negative one if no such construction is possible.

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

Shortest Way to Form String gives source and target strings. Return the fewest subsequences of source that can be concatenated to form target, or negative one if no such construction is possible.

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.