mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 23:41:41 +08:00
update
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<p>Given a characters array <code>letters</code> that is sorted in <strong>non-decreasing</strong> order and a character <code>target</code>, return <em>the smallest character in the array that is larger than </em><code>target</code>.</p>
|
||||
|
||||
<p><strong>Note</strong> that the letters wrap around.</p>
|
||||
|
||||
<ul>
|
||||
<li>For example, if <code>target == 'z'</code> and <code>letters == ['a', 'b']</code>, the answer is <code>'a'</code>.</li>
|
||||
</ul>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> letters = ["c","f","j"], target = "a"
|
||||
<strong>Output:</strong> "c"
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> letters = ["c","f","j"], target = "c"
|
||||
<strong>Output:</strong> "f"
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 3:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> letters = ["c","f","j"], target = "d"
|
||||
<strong>Output:</strong> "f"
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>2 <= letters.length <= 10<sup>4</sup></code></li>
|
||||
<li><code>letters[i]</code> is a lowercase English letter.</li>
|
||||
<li><code>letters</code> is sorted in <strong>non-decreasing</strong> order.</li>
|
||||
<li><code>letters</code> contains at least two different characters.</li>
|
||||
<li><code>target</code> is a lowercase English letter.</li>
|
||||
</ul>
|
Reference in New Issue
Block a user