Design Gurus Logo
Maximum Length of a Concatenated String with Unique Characters (medium)

Problem Statement

Given an array arr containing strings, return the maximum length of the string that can be formed by the concatenations of the subsequence of arr, having unique characters.

A subsequence is an array that can be formed from arr by deleting 0 or more elements without changing the order of the remaining elements.

Examples

  • Example 1:

    • Input: ["ab", "cd", "e"]
    • Expected Output: 5
    • Justification: Concatenating "ab", "cd", and "e" forms "abcde" which has all unique characters and is of maximum length 5.
  • Example 2:

    • Input: ["a", "abc", "d", "de", "def"]
    • xpected Output: 6
    • Justification: Concatenating "abc", and "def" forms "abcdef" which has all unique characters and is of maximum length 6.
  • Example 3:

    • Input: ["xyz", "y", "z"]
    • Expected Output: 3
    • Justification: We can choose only "xyz" string. Hence, the maximum length is 3.

Try it yourself

Try solving this question here:

Python3
Python3

. . . .

.....

.....

.....

Unlock this and all other premium problems.
No code editor for this lesson
This lesson focuses on concepts and theory