We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fbc831e commit 3a87238Copy full SHA for 3a87238
1 file changed
live8/test87/문제1/이상민.js
@@ -0,0 +1,12 @@
1
+function solution(numbers) {
2
+ const answer = Array.from({ length: numbers.length }, () => -1);
3
+ const stack = [];
4
+
5
+ for (let i = 0; i < numbers.length; i++) {
6
+ while (stack.length > 0 && numbers[stack.at(-1)] < numbers[i]) {
7
+ answer[stack.pop()] = numbers[i];
8
+ }
9
+ stack.push(i);
10
11
+ return answer;
12
+}
0 commit comments