Longest Repeated Block Problem
Longest Repeated Block Problem — ExecCode Hard DSA Practice
Solve the Longest Repeated Block problem on ExecCode. Free online hard DSA practice in String. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Find the length of the longest substring that appears at least twice (occurrences may overlap). A suffix array plus LCP array: the maximum LCP between adjacent suffixes is the answer. A suffix automaton computes the same with endpos sets. Return that length. If every character is unique as a long block, a single character repeat still counts as 1 when a letter appears twice. You are given: s — the text Return longest duplicated substring length. In aaa, aa appears twice overlapping, length 2.
Examples
Input {'s': 'banana'}; Output 3. Input {'s': 'abc'}; Output 0. Input {'s': 'aaaa'}; Output 3
Constraints
Empty string 0 Overlaps allowed
Practice Longest Repeated Block free on ExecCode. Browse DSA problems, topic map, and placement guides.