Class Solution
java.lang.Object
g0501_0600.s0503_next_greater_element_ii.Solution
503 - Next Greater Element II.<p>Medium</p>
<p>Given a circular integer array <code>nums</code> (i.e., the next element of <code>nums[nums.length - 1]</code> is <code>nums[0]</code>), return <em>the <strong>next greater number</strong> for every element in</em> <code>nums</code>.</p>
<p>The <strong>next greater number</strong> of a number <code>x</code> is the first greater number to its traversing-order next in the array, which means you could search circularly to find its next greater number. If it doesn’t exist, return <code>-1</code> for this number.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums = [1,2,1]</p>
<p><strong>Output:</strong> [2,-1,2] Explanation:</p>
<p>The first 1’s next greater number is 2;</p>
<p>he number 2 can’t find next greater number.</p>
<p>The second 1’s next greater number needs to search circularly, which is also 2.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums = [1,2,3,4,3]</p>
<p><strong>Output:</strong> [2,3,4,-1,4]</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= nums.length <= 10<sup>4</sup></code></li>
<li><code>-10<sup>9</sup> <= nums[i] <= 10<sup>9</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
nextGreaterElements
public int[] nextGreaterElements(int[] nums)
-