Tap here to switch tabs
Problem
Submissions

Problem: Short Encoding of Words

Short Encoding of Words gives an array of strings and asks for the minimum length of a reference string that identifies each word by an index and a following hash character.

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

Short Encoding of Words gives an array of strings and asks for the minimum length of a reference string that identifies each word by an index and a following hash character.

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.