Medium · Backtracking

Maximum Length of a Concatenated String with Unique Characters

Given an array arr of lowercase strings, return the maximum length of a string formed by concatenating some of them (kept in their original order) whose characters are all distinct; return 0 if no string can be used.

Examples

Example 1

["un","iq","ue"]

Output: max 4

Example 2

["cha","r","act","ers"]

Output: max 6

Rebuild it in the studio

Open every published interview problem, solution, scene, and memory room free, with no account.

More Backtracking problems