<p>Given a string <code>s</code>, consider all <em>duplicated substrings</em>: (contiguous) substrings of s that occur 2 or more times.&nbsp;The occurrences&nbsp;may overlap.</p>

<p>Return <strong>any</strong> duplicated&nbsp;substring that has the longest possible length.&nbsp;If <code>s</code> does not have a duplicated substring, the answer is <code>&quot;&quot;</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre><strong>Input:</strong> s = "banana"
<strong>Output:</strong> "ana"
</pre><p><strong class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> s = "abcd"
<strong>Output:</strong> ""
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>2 &lt;= s.length &lt;= 3 * 10<sup>4</sup></code></li>
	<li><code>s</code> consists of lowercase English letters.</li>
</ul>

class Solution:
    def longestDupSubstring(self, s: str) -> str:
        l, r = 1, len(s) - 1
        res = ""
        while l <= r:
            m = (l+r) // 2
            idx = self.check(s, m)
            if idx > 0:
                res = s[idx:idx + m]
                l = m+1
            else :
                r = m-1
        return res
            
    def check(self, s, l):
        seen = set()
        for i in range(len(s)-l+1):
            sub_s = s[i:i+l]
            if sub_s in seen:
                print(sub_s, l)
                return i
            seen.add(sub_s)
        return -1
241000