Python | DFS | Explained w/ Comments
\ndef maxLength(self, arr):\n\t# Check if the concatenated-string has unique characters or not\n\tdef isValid(s):\n\t\tunique = [False]*26\n\t\tfor i in range(l
```\ndef maxLength(self, arr):\n\t# Check if the concatenated-string has unique characters or not\n\tdef isValid(s):\n\t\tunique = [False]*26\n\t\tfor i in range(len(s)):\n\t\t\tif not unique[ord(s[i])-ord(\'a\')]: unique[ord(s[i])-ord(\'a\')] = True\n\t\t\telse: return False\n\t\treturn True\n\n\t# Do a DFS on all the individual array elements\n\tdef dfs(path, l, r):\n\t\t# If path has non-zero length then that means this is a potential solution\n\t\tif path:\n\t\t\tself.ans = max(self.ans, len(path))\n\n\t\tfor i in range(l ,r):\n\t\t\tif isValid(path+arr[i]):\n\t\t\t\tdfs(path+arr[i], i+1, r)\n\n\tself.ans = float(\'-inf\')\n\tdfs("", 0, len(arr))\n\n\treturn self.ans if self.ans != float(\'-inf\') else 0\n```\n\n**A smal note**: If you are new to backtracking questions, this can be a good question for you to practice. This questions is one solid implementation of a very common pattern which you will find in a lot of backtracking questions. I was not good at backtracking because I couldn\'t think what should be done for such type of questions. Answer is, to find a template -- everyone has a unqiue one in their mind. You will get one imprinted too if you practice.
['Backtracking', 'Depth-First Search', 'Python']