🔥5 lines of main code ✅ || Easy to understand 👍|| Beat 95% users time and 100% space complexity 🚀
Intuition\n# Python and Python3 :\n1. combinations from itertools: The code uses the combinations function from the itertools module. This function generates al
# Intuition\n# **Python and Python3 :**\n1. **combinations from itertools:** The code uses the **combinations** function from the **itertools** module. This function generates all possible combinations of a given iterable.\n2. **Initialize res to 0:** **\'res\'** is a variable that keeps track of the maximum length found during the iteration. It starts with a value of 0.\n3. **Iterate over all possible lengths of subsequences (i):** The outer loop goes from 1 to the length of the input array (**\'arr\'**). This represents the length of subsequences that we are considering.\n4. **Generate combinations of strings with the current length (i):** The inner loop uses **\'combinations\'** to generate all combinations of strings with the current length (**\'i\'**). Each **\'j\'** is a tuple containing **\'i\'** strings from the original array.\n5. **Join the strings in the combination (c):** The **\'join\'** method is used to concatenate the strings in the current combination into a single string.\n**lets understand it with the example take the 1st testcase:**\narr=["un","iq","ue"]\nfor i in range(1,len(arr)+1):\n    for j in combinations(arr,i):\n        c=\'\'.join(j)\n        print("j=",j,"c=",c)  # here we print(j,c) to se how the combinations were made\n        if len(set(c))==len(c):\n            res=max(res,len(c))\nlets check the print line\'s output:\nj= (\'un\',) c= un\nj= (\'iq\',) c= iq\nj= (\'ue\',) c= ue\nj= (\'un\', \'iq\') c= uniq\nj= (\'un\', \'ue\') c= unue\nj= (\'iq\', \'ue\') c= ique\nj= (\'un\', \'iq\', \'ue\') c= unique\n\n   **so you can understand from here how combinations works \uD83D\uDC4D**\n\n\n6. **Check for uniqueness in the current combination:** The **\'set(c)\'** converts the string into a set of characters, effectively removing duplicates. If the length of the set is equal to the length of the string, it means all characters are unique.\n6. **Update res if the current combination is valid:** If the current combination has unique characters and its length is greater than the current **\'res\'**, update **\'res\'**.\n7. **Return the final res:** After iterating over all possible combinations and lengths, return the maximum length found.\n\n**I hope you understand the code \uD83D\uDE4F**\n\n# Approach : Combinations of Itertools\n\n# Complexity\n- Time complexity: O(2^n)\n\n- Space complexity: O(2^n)\n\n# Code\n```Python3 []\nclass Solution:\n    def maxLength(self, arr: List[str]) -> int:\n        res=0\n        for i in range(1,len(arr)+1):\n            for j in combinations(arr,i):\n                c=\'\'.join(j)\n                if len(set(c))==len(c):\n                    res=max(res,len(c))\n\n        return res\n```\n```python []\nclass Solution(object):\n    def maxLength(self, arr):\n        """\n        :type arr: List[str]\n        :rtype: int\n        """\n        res=0\n        for i in range(1,len(arr)+1):\n            for j in combinations(arr,i):\n                c=\'\'.join(j)\n                if len(set(c))==len(c):\n                    res=max(res,len(c))\n\n        return res\n```\n
['Array', 'String', 'Python', 'Python3']