https://leetcode.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters/
你會得到一個裝滿字串的陣列arr,請用arr中的字串組合一個沒有任何字母重複的字串s。
請回傳所有可能的組合中最長的長度。

這題的解法是要從arr中找出所有符合條件的字串,並讓符合條件的字串和其他字串做組合
class Solution:
    def maxLength(self, arr: List[str]) -> int:
        
        unique = ['']
        ans = 0
        
        for i in range(len(arr)):
            
            for j in range(len(unique)):
                
                word = arr[i] + unique[j]
                
                if len(word) == len(set(word)):
                    unique.append(word)
                    ans = max(ans, len(word))
        return ans
今天的題目除了上面的解法外,還有很多種解法,可用dp、backtracking甚至還有bit-manipulation
一題可以滿足多種練習需求