✅☑Beats 100% Users || Easy Understood Solution With space[n] and time[O(2^n)] || 2 Approaches🔥
Complexity\n- Time complexity: O(2^n) \n Add your time complexity here, e.g. O(n) \n\n- Space complexity:  O(n)\n Add your space complexity here, e.g. O(n) \n# 
# Complexity\n- Time complexity: O(2^n) \n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:  O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n# code 1 \n```\nclass Solution:\n    # Method to check for duplicates in two arrays\n    def dup(self, arr1, arr2):\n        a = {}  # Initialize a dictionary to store unique elements\n        for i in arr1:\n            if i in a:\n                return True  # Return True if a duplicate is found in arr1\n            if i not in a:\n                a[i] = 1  # Add the element to the dictionary if not present\n        for i in arr2:\n            if i in a:\n                return True  # Return True if a duplicate is found in arr2\n        return False  # Return False if no duplicates are found in both arrays\n\n    # Recursive method to explore combinations and find maximum length\n    def check(self, i, a, temp, n):\n        if i >= n:\n            return len(temp)  # Return the length of the current combination if all elements are considered\n        \n        exclude = self.check(i + 1, a, temp, n)  # Explore the exclude case\n        \n        if not self.dup(a[i], temp):\n            include = self.check(i + 1, a, temp + a[i], n)  # Explore the include case if adding the current element doesn\'t introduce duplicates\n            return max(exclude, include)  # Return the maximum length obtained\n        \n        return exclude  # Return the length obtained in the exclude case\n\n    # Method to find the maximum length of a string without duplicates\n    def maxLength(self, arr: List[str]) -> int:\n        temp = ""  # Initialize current combination as an empty string\n        i = 0  # Start exploring from the beginning of the array\n        n = len(arr)  # Total number of strings in the array\n        return self.check(i, arr, temp, n)  # Call the recursive method to get the result\n\n```\n\n# Code 2 (dp)\n```\nclass Solution:\n    # Method to check for duplicates in two arrays\n    def dup(self, arr1, arr2):\n        seen = set()\n        for i in arr1:\n            if i in seen:\n                return True\n            seen.add(i)\n        for i in arr2:\n            if i in seen:\n                return True\n        return False\n\n    # Recursive method to explore combinations and find maximum length\n    def check(self, i, a, temp, n, dp):\n        # Base case: If the current combination is already memoized, return its length\n        if temp in dp:\n            return dp[temp]\n        # Base case: If we have considered all elements, return the length of the current combination\n        if i >= n:\n            return len(temp)\n        \n        # Initialize variables for include and exclude cases\n        include = 0\n        exclude = self.check(i + 1, a, temp, n, dp)\n        \n        # Explore include case only if adding the current string doesn\'t introduce duplicates\n        if not self.dup(a[i], temp):\n            include = self.check(i + 1, a, temp + a[i], n, dp)\n        \n        # Memoize the maximum length and return it\n        dp[temp] = max(exclude, include)\n        return dp[temp]\n\n    # Method to find the maximum length of a string without duplicates\n    def maxLength(self, arr: List[str]) -> int:\n        temp = ""  # Initialize current combination as an empty string\n        i = 0       # Start exploring from the beginning of the array\n        n = len(arr)  # Total number of strings in the array\n        dp = {}     # Memoization dictionary to store already computed results\n        return self.check(i, arr, temp, n, dp)  # Call the recursive method to get the result\n\n# Example usage:\n# solution = Solution()\n# arr = ["un", "iq", "ue"]\n# result = solution.maxLength(arr)\n# print(result)\n\n\n```\n![leetcode up1.png](https://assets.leetcode.com/users/images/b3fd9b35-edec-4328-8fbf-986edefc6f8b_1706017690.4730418.jpeg)\n
['Hash Table', 'Dynamic Programming', 'Hash Function', 'Ordered Set', 'Python', 'Python3']