Longest duplicate substring
Given a string s of lowercase letters (1 <= len(s) <= 3*10^4), return the longest substring that occurs at least twice in s (occurrences may overlap). If no character repeats such that a duplicated substring exists, return the empty string. If several answers of the same maximal length exist, returning any one of them is acceptable, but for these tests return the FIRST (lowest second-occurrence index) found by the standard binary-search-plus-rolling-hash method.
Implement
longest_dup_substring(s: str) → strExamples
in
["banana"]out"ana"What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 40 min
solution.py
InputExpectedGot
["banana"]"ana"not run yetsample