|
@@ -1,27 +1,9 @@
|
|
|
import java.nio.file.Files;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Base64;
|
|
|
-import java.util.BitSet;
|
|
|
-import java.util.Stack;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.*;
|
|
|
|
|
|
public class tmp {
|
|
|
public static void main(String[] args) throws InterruptedException {
|
|
|
- int[] ints = {2, 1, 2, 4, 3};
|
|
|
- nextGreaterElement(ints);
|
|
|
- }
|
|
|
-
|
|
|
- public static int[] nextGreaterElement(int[] nums) {
|
|
|
- int n = nums.length;
|
|
|
- int[] res = new int[n];
|
|
|
- Stack<Integer> stack = new Stack<>();
|
|
|
- for (int i = n - 1; i >= 0; i--) {
|
|
|
- while (!stack.isEmpty() && stack.peek() <= nums[i]) {
|
|
|
- stack.pop();
|
|
|
- }
|
|
|
- res[i] = stack.isEmpty() ? -1 : stack.peek();
|
|
|
- stack.push(nums[i]);
|
|
|
- }
|
|
|
- return res;
|
|
|
+ TimeUnit.SECONDS.sleep(3);
|
|
|
}
|
|
|
}
|