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

Core interview problems are free with a full runner and lessons; Pro opens the complete library.

More Backtracking problems