Skip to content

Commit c07765a

Browse files
authored
Merge pull request #1205 from AlgorithmWithGod/ksinji
[20251023] PGM / LV2 / 주식가격 / 강신지
2 parents 3035929 + b5f08c0 commit c07765a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
```java
2+
class Solution {
3+
public int[] solution(int[] prices) {
4+
int[] answer = new int[prices.length];
5+
6+
for(int i = 0; i<prices.length; i++){
7+
if (prices[i] == 1) {
8+
answer[i] = prices.length-i-1;
9+
continue;
10+
}
11+
int cnt = 0;
12+
for (int j=i+1; j<prices.length; j++){
13+
if (prices[j] < prices[i]) {
14+
answer[i] = ++cnt;
15+
break;
16+
}
17+
else cnt++;
18+
}
19+
answer[i] = cnt;
20+
}
21+
return answer;
22+
}
23+
}
24+
```

0 commit comments

Comments
 (0)