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

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Backtracking problems