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)/下一个更大元素 III [next-greater-element-iii].html
2022-03-29 12:43:11 +08:00

28 lines
836 B
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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>n</code> ,请你找出符合条件的最小整数,其由重新排列 <code>n</code><strong> </strong>中存在的每位数字组成,并且其值大于 <code>n</code> 。如果不存在这样的正整数,则返回 <code>-1</code></p>
<p><strong>注意</strong> ,返回的整数应当是一个 <strong>32 位整数</strong> ,如果存在满足题意的答案,但不是 <strong>32 位整数</strong> ,同样返回 <code>-1</code></p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>n = 12
<strong>输出:</strong>21
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>n = 21
<strong>输出:</strong>-1
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= n <= 2<sup>31</sup> - 1</code></li>
</ul>