Search
⌘K

Leetcode 3291. Minimum Number of Valid Strings to Form Target I

Given words and a target, each valid piece is any prefix of any word; return the minimum number of such prefixes that concatenate to form target, or -1 if impossible. This is a shortest-segmentation problem based on prefix matching (solvable with DP/trie) with target length up to ~5k and total words length up to ~1e5.

Asked at:

Meta


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Late May, 2025

Meta

Senior

Mid September, 2024

Meta

Mid-level

Variation of Stickers to Spell Word - Given a single word sticker, find minimum number of stickers needed to spell target word

Comments

Your account is free and you can post anonymously if you choose.