GeeksforGeeks » Interview Questions
Amazon Interview Question for Software Engineer/Developer (Fresher) about Data Structure
(5 posts)-
find the longest repeated substring given an input string. eg. given "banana" you should find "anana"
-
This problem can be solved in linear time and space by building a suffix tree for the string, and finding the deepest internal node in the tree. The string spelled by the edges from the root to such a node is a longest repeated substring. The problem of finding the longest substring with at least k occurrences can be found by first preprocessing the tree to count the number of leaf descendants for each internal node, and then finding the deepest node with at least k descendants.
Source http://en.wikipedia.org/wiki/Longest_repeated_substring_problem
-
@Ankit Can U Please give some more example what do u mean by longest repeated substring....m no confused..??
-
Isn't the longest repeated substring of banana is 'ana'.. Howcome 'anana'?? Please answer..
-
Hi Geeks have a Look & Please Comment if anything wrong or any other approach to solve the same , will appriciate if anyone can post suffix tree solution with explanation ?
http://shashank7s.blogspot.com/2011/06/longest-repeated-substring-eg-maximum.html
Shashank!!!
Reply
You must log in to post.