Tap here to switch tabs
Problem
Submissions

Problem: Longest Duplicate Substring

med
30 min
Try to solve the Longest Duplicate Substring problem.

Statement

Given a string s, return the longest substring of s that appears at least twice within s. The repeated occurrences may overlap. If there is no duplicated substring, return an empty string.

Note: If multiple answers have the same maximum length, returning any one of them is acceptable.

Constraints:

  • 2≤2 \leq s.length ≤3⋅104\leq 3 \cdot 10^4

  • s consists of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Longest Duplicate Substring

med
30 min
Try to solve the Longest Duplicate Substring problem.

Statement

Given a string s, return the longest substring of s that appears at least twice within s. The repeated occurrences may overlap. If there is no duplicated substring, return an empty string.

Note: If multiple answers have the same maximum length, returning any one of them is acceptable.

Constraints:

  • 2≤2 \leq s.length ≤3⋅104\leq 3 \cdot 10^4

  • s consists of lowercase English letters.