【Microsoft面经】OA 2019 | Concatenated String Length with unique Characters Microsoft OA 开发岗

胖蛋 2020-5-9 2084


Given an Array A consisting of N Strings, calculate the length of the longest string S such that:

  • S is a concatenation of some of the Strings from A.
  • every letter in S is different.

Example - A = ["co","dil","ity"] , function should return 5, resulting string S could be codil , dilco, coity,ityco A = ["abc","kkk","def","csv"] , returns 6 , resulting Strings S could be abcdef , defabc, defcsv , csvdef A = ["abc","ade","akl"] , return 0 , impossible to concatenate as letters wont be unique.

N is [1..8] ; A consists of lowercase English letters ; sum of length of strings in A does not exceed 100.

最后于 2020-6-1 被maomoke编辑 ,原因:
最新回复 (0)
返回