Tap here to switch tabs
Problem
Submissions

Problem: Short Encoding of Words

med
30 min
Try to solve the Short Encoding of Words problem.

Statement

A valid encoding of an array of strings words consists of a reference string s and an array of indices indices satisfying the following conditions:

  • words.length is equal to indices.length.

  • For each index i, the substring of s starting at indices[i] and extending up to the next '#' character is equal to words[i].

Given an array of strings words, return the minimum possible length of any reference string s that validly encodes words.

Constraints:

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

  • 1≤1 \leq words[i].length ≤7\leq 7

  • words[i] consists of only lowercase letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Short Encoding of Words

med
30 min
Try to solve the Short Encoding of Words problem.

Statement

A valid encoding of an array of strings words consists of a reference string s and an array of indices indices satisfying the following conditions:

  • words.length is equal to indices.length.

  • For each index i, the substring of s starting at indices[i] and extending up to the next '#' character is equal to words[i].

Given an array of strings words, return the minimum possible length of any reference string s that validly encodes words.

Constraints:

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

  • 1≤1 \leq words[i].length ≤7\leq 7

  • words[i] consists of only lowercase letters.