Search
⌘K

Leetcode 3253. Construct String with Minimum Cost (Easy)

Given a target string and two operations—append the next character at cost addCost or copy any substring that already appears in the built prefix at fixed cost copyCost—compute the minimum cost to construct the whole string. This is solved by dynamic programming combined with substring-matching (e.g., KMP or rolling hash) to determine the maximal copyable segment from each position.


Question Timeline

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

Comments

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