mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
36 lines
1.3 KiB
HTML
36 lines
1.3 KiB
HTML
|
<p>请从字符串中找出一个最长的不包含重复字符的子字符串,计算该最长子字符串的长度。</p>
|
||
|
|
||
|
<p> </p>
|
||
|
|
||
|
<p><strong>示例 1:</strong></p>
|
||
|
|
||
|
<pre><strong>输入: </strong>"abcabcbb"
|
||
|
<strong>输出: </strong>3
|
||
|
<strong>解释:</strong> 因为无重复字符的最长子串是 <code>"abc",所以其</code>长度为 3。
|
||
|
</pre>
|
||
|
|
||
|
<p><strong>示例 2:</strong></p>
|
||
|
|
||
|
<pre><strong>输入: </strong>"bbbbb"
|
||
|
<strong>输出: </strong>1
|
||
|
<strong>解释: </strong>因为无重复字符的最长子串是 <code>"b"</code>,所以其长度为 1。
|
||
|
</pre>
|
||
|
|
||
|
<p><strong>示例 3:</strong></p>
|
||
|
|
||
|
<pre><strong>输入: </strong>"pwwkew"
|
||
|
<strong>输出: </strong>3
|
||
|
<strong>解释: </strong>因为无重复字符的最长子串是 <code>"wke"</code>,所以其长度为 3。
|
||
|
请注意,你的答案必须是 <strong>子串 </strong>的长度,<code>"pwke"</code> 是一个<em>子序列,</em>不是子串。
|
||
|
</pre>
|
||
|
|
||
|
<p> </p>
|
||
|
|
||
|
<p>提示:</p>
|
||
|
|
||
|
<ul>
|
||
|
<li><code>s.length <= 40000</code></li>
|
||
|
</ul>
|
||
|
|
||
|
<p>注意:本题与主站 3 题相同:<a href="https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/">https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/</a></p>
|