Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Valid Strings to Form Target I

Minimum Number of Valid Strings to Form Target I asks you to concatenate the fewest prefixes of the given words to create target, or return minus one if it cannot be formed.

Statement

You are given an array of strings words and a string target.

A string is considered valid if it is a prefix of at least one string present in words.

Return the minimum number of valid strings required to concatenate and form target. If it is impossible to form target using valid strings, return −1-1.

Constraints:

  • 1≤1 \leq words.length ≤100\leq 100

  • 1≤1 \leq words[i].length ≤5×103\leq 5 \times 10^3

  • The sum of words[i].length across all elements is at most 10510^5.

  • words[i] consists only of lowercase English letters.

  • 1≤1 \leq target.length ≤5×103\leq 5 \times 10^3

  • target consists only of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Valid Strings to Form Target I

Minimum Number of Valid Strings to Form Target I asks you to concatenate the fewest prefixes of the given words to create target, or return minus one if it cannot be formed.

Statement

You are given an array of strings words and a string target.

A string is considered valid if it is a prefix of at least one string present in words.

Return the minimum number of valid strings required to concatenate and form target. If it is impossible to form target using valid strings, return −1-1.

Constraints:

  • 1≤1 \leq words.length ≤100\leq 100

  • 1≤1 \leq words[i].length ≤5×103\leq 5 \times 10^3

  • The sum of words[i].length across all elements is at most 10510^5.

  • words[i] consists only of lowercase English letters.

  • 1≤1 \leq target.length ≤5×103\leq 5 \times 10^3

  • target consists only of lowercase English letters.