Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Valid Strings to Form Target I

Try to solve the Minimum Number of Valid Strings to Form Target I problem.

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 ≤5imes103\leq 5 imes 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 ≤5imes103\leq 5 imes 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

Try to solve the Minimum Number of Valid Strings to Form Target I problem.

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 ≤5imes103\leq 5 imes 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 ≤5imes103\leq 5 imes 10^3

  • target consists only of lowercase English letters.