1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 11:08:15 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/寻找比目标字母大的最小字母 [find-smallest-letter-greater-than-target].html
2022-03-29 12:43:11 +08:00

43 lines
1.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个排序后的字符列表 <code>letters</code> ,列表中只包含小写英文字母。另给出一个目标字母&nbsp;<code>target</code>,请你寻找在这一有序列表里比目标字母大的最小字母。</p>
<p>在比较时,字母是依序循环出现的。举个例子:</p>
<ul>
<li>如果目标字母 <code>target = 'z'</code> 并且字符列表为&nbsp;<code>letters = ['a', 'b']</code>,则答案返回&nbsp;<code>'a'</code></li>
</ul>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入: </strong>letters = ["c", "f", "j"]target = "a"
<strong>输出:</strong> "c"
</pre>
<p><strong>示例 2:</strong></p>
<pre>
<strong>输入:</strong> letters = ["c","f","j"], target = "c"
<strong>输出:</strong> "f"
</pre>
<p><strong>示例 3:</strong></p>
<pre>
<strong>输入:</strong> letters = ["c","f","j"], target = "d"
<strong>输出:</strong> "f"
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>2 &lt;= letters.length &lt;= 10<sup>4</sup></code></li>
<li><code>letters[i]</code>&nbsp;是一个小写字母</li>
<li><code>letters</code> 按非递减顺序排序</li>
<li><code>letters</code> 最少包含两个不同的字母</li>
<li><code>target</code> 是一个小写字母</li>
</ul>