mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
31 lines
855 B
HTML
31 lines
855 B
HTML
|
<p>给你一个字符串 <code>s</code> ,字符串的<strong>「能量」</strong>定义为:只包含一种字符的最长非空子字符串的长度。</p>
|
|||
|
|
|||
|
<p>请你返回字符串 <code>s</code> 的 <strong>能量</strong>。</p>
|
|||
|
|
|||
|
<p> </p>
|
|||
|
|
|||
|
<p><strong>示例 1:</strong></p>
|
|||
|
|
|||
|
<pre>
|
|||
|
<strong>输入:</strong>s = "leetcode"
|
|||
|
<strong>输出:</strong>2
|
|||
|
<strong>解释:</strong>子字符串 "ee" 长度为 2 ,只包含字符 'e' 。
|
|||
|
</pre>
|
|||
|
|
|||
|
<p><strong>示例 2:</strong></p>
|
|||
|
|
|||
|
<pre>
|
|||
|
<strong>输入:</strong>s = "abbcccddddeeeeedcba"
|
|||
|
<strong>输出:</strong>5
|
|||
|
<strong>解释:</strong>子字符串 "eeeee" 长度为 5 ,只包含字符 'e' 。
|
|||
|
</pre>
|
|||
|
|
|||
|
<p> </p>
|
|||
|
|
|||
|
<p><strong>提示:</strong></p>
|
|||
|
|
|||
|
<ul>
|
|||
|
<li><code>1 <= s.length <= 500</code></li>
|
|||
|
<li><code>s</code> 只包含小写英文字母。</li>
|
|||
|
</ul>
|