We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents bda099e + a2e0ac9 commit 8aaab1cCopy full SHA for 8aaab1c
LiiNi-coder/202511/13 PGM 주식가격.md
@@ -0,0 +1,31 @@
1
+```java
2
+import java.util.*;
3
+
4
+class Solution {
5
+ public int[] solution(int[] prices) {
6
+ int n = prices.length;
7
+ int[] answer = new int[n];
8
+ ArrayDeque<Integer> stack = new ArrayDeque<>();
9
10
+ for(int i= 0; i < n; i++){
11
+ while(!stack.isEmpty()){
12
+ if(prices[stack.peekLast()] > prices[i]){
13
+ int index = stack.pollLast();
14
+ answer[index] = i - index;
15
+ }else{
16
+ break;
17
+ }
18
19
+ stack.offerLast(i);
20
21
22
23
24
+ int idx = stack.pollLast();
25
+ answer[idx] = n - 1 - idx;
26
27
+ return answer;
28
29
+}
30
31
+```
0 commit comments