May 10, 2017 · T is a rooted tree having exactly L+1 leaves. Every edge of T is labeled with a substring of s$, where s$ is the string formed by adding a placeholder symbol $ to the end of s. Every internal node of T other than the root has at least two children; i.e., it has degree at least 3. Lets look at following figure: This is suffix tree for string “ABABABA$”. In this string, following substrings are repeated: A, B, AB, BA, ABA, BAB, ABAB, BABA, ABABA And Longest Repeated Substring is ABABA. In a suffix tree, one node can’t have more than one outgoing edge starting...

#!/usr/bin/env python ''' Leetcode: Longest Substring Without Repeating Characters: Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest substring is "b", with the length of 1. In computer science, the longest repeated substring problem is the problem of finding the longest substring of a string that occurs at least twice.. This problem can be solved in linear time and space () by building a suffix tree for the string (with a special end-of-string symbol like '$' appended), and finding the deepest internal node in the tree.