← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Practice/Amazon/Leetcode 1044. Longest Duplicate Substring
CodingMust
Given a string consisting of lowercase English letters, find the longest substring that appears at least twice in the string. The occurrences of this substring are allowed to overlap.
If no such substring exists, return an empty string.
Example 1:
Input: s = "banana" Output: "ana" Explanation: The substring "ana" appears twice: at index 1 ("b[ana]na") and index 3 ("ban[ana]")
Example 2:
Input: s = "abcd" Output: "" Explanation: No substring appears more than once
Example 3:
Input: s = "aabcaab" Output: "aab" Explanation: The substring "aab" appears at index 0 and index 4