mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 23:41:41 +08:00
存量题库数据更新
This commit is contained in:
@@ -1,31 +1,30 @@
|
||||
<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>You are given an array of characters <code>letters</code> that is sorted in <strong>non-decreasing order</strong>, and a character <code>target</code>. There are <strong>at least two different</strong> characters in <code>letters</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>Return <em>the smallest character in </em><code>letters</code><em> that is lexicographically greater than </em><code>target</code>. If such a character does not exist, return the first character in <code>letters</code>.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> letters = ["c","f","j"], target = "a"
|
||||
<strong>Output:</strong> "c"
|
||||
<strong>Explanation:</strong> The smallest character that is lexicographically greater than 'a' in letters is 'c'.
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
<p><strong class="example">Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> letters = ["c","f","j"], target = "c"
|
||||
<strong>Output:</strong> "f"
|
||||
<strong>Explanation:</strong> The smallest character that is lexicographically greater than 'c' in letters is 'f'.
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 3:</strong></p>
|
||||
<p><strong class="example">Example 3:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> letters = ["c","f","j"], target = "d"
|
||||
<strong>Output:</strong> "f"
|
||||
<strong>Input:</strong> letters = ["x","x","y","y"], target = "z"
|
||||
<strong>Output:</strong> "x"
|
||||
<strong>Explanation:</strong> There are no characters in letters that is lexicographically greater than 'z' so we return letters[0].
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
Reference in New Issue
Block a user