GeeksforGeeks » Interview Questions

Amazon Interview Question for Software Engineer/Developer (Fresher) about Data Structure

(5 posts)
  1. Ankit
    guest
    Posted 1 year ago #

    find the longest repeated substring given an input string. eg. given "banana" you should find "anana"

  2. kapil
    guest
    Posted 1 year ago #

    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

  3. rama
    guest
    Posted 1 year ago #

    @Ankit Can U Please give some more example what do u mean by longest repeated substring....m no confused..??

  4. Vallab C
    guest
    Posted 8 months ago #

    Isn't the longest repeated substring of banana is 'ana'.. Howcome 'anana'?? Please answer..

  5. WgpShashank
    guest
    Posted 8 months ago #

    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.

RSS feed for this topic