# What is a time complexity for finding the longest substring that is repeated in a string?

Category: QuestionsWhat is a time complexity for finding the longest substring that is repeated in a string?
Editor">Editor Staff asked 5 months ago

What is a time complexity for finding the longest substring that is repeated in a string?

(a) O (log n!)

(b) Ɵ (n!)

(c) O (n^2+ n1)

(d) Ɵ (n)

This interesting question is from Suffix tree topic in chapter Trie of Data Structures & Algorithms I

This question was addressed to me during an internship interview.

Editor">Editor Staff answered 5 months ago

Right choice is (d) Ɵ (n)

Easiest explanation – Suffix Tree allows fast string operation. To check if a substring is present in a string of a length of n, the time complexity for such operation is found to be O (n). The time complexity for finding the longest substring that is repeated in a string is Ɵ (n).

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17
Articles: 40702