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

39 lines
1.5 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>,该数组按<strong>非递减顺序</strong>排序,以及一个字符 <code>target</code><code>letters</code>&nbsp;<strong>至少有两个不同</strong>的字符。</p>
<p>返回&nbsp;<code>letters</code>&nbsp;中大于 <code>target</code> 的最小的字符。如果不存在这样的字符,则返回&nbsp;<code>letters</code> 的第一个字符。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入: </strong>letters = ["c", "f", "j"]target = "a"
<strong>输出:</strong> "c"
<strong>解释:</strong>letters 中字典上比 'a' 大的最小字符是 'c'。</pre>
<p><strong>示例 2:</strong></p>
<pre>
<strong>输入:</strong> letters = ["c","f","j"], target = "c"
<strong>输出:</strong> "f"
<strong>解释:</strong>letters 中字典顺序上大于 'c' 的最小字符是 'f'。</pre>
<p><strong>示例 3:</strong></p>
<pre>
<strong>输入:</strong> letters = ["x","x","y","y"], target = "z"
<strong>输出:</strong> "x"
<strong>解释:</strong>letters 中没有一个字符在字典上大于 'z',所以我们返回 letters[0]。</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><strong>非递减顺序</strong>排序</li>
<li><code>letters</code> 最少包含两个不同的字母</li>
<li><code>target</code> 是一个小写字母</li>
</ul>