Skip to content

Commit fcd66ac

Browse files
authored
Create 프로그래머스_뒤에있는큰수찾기.java
1 parent 4a0bf9a commit fcd66ac

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import java.util.*;
2+
class Solution {
3+
public int[] solution(int[] numbers) {
4+
int [] answer = new int[numbers.length];
5+
int seq = 0;
6+
Stack<Integer> stack = new Stack<>();
7+
Arrays.fill(answer,-1);
8+
9+
10+
for (int i = 0; i < numbers.length;i++) {
11+
12+
while(!stack.isEmpty() && numbers[stack.peek()] < numbers[i]) {
13+
answer[stack.pop()] = numbers[i];
14+
}
15+
stack.push(i);
16+
}
17+
18+
return answer;
19+
}
20+
}

0 commit comments

Comments
 (0)