Longest Duplicate Substring LeetCode solution in Python
1# Runtime: 2799 ms (Top 43.0%) | Memory: 16.80 MB (Top 93.0%)234class Solution:5def longestDupSubstring(self, s: str) -> str:6left = 07right = 18res = ""9n = len(s)10while right < n:11if s[left:right] in s[left + 1 :]:12if right - left > len(res):13res = s[left:right]14right += 115continue16left += 117if left == right:18right += 119return res