Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 |
Tags
- 자바
- binary search
- 코딩테스트
- 문자열
- db
- BOJ
- 운동기록
- greedy
- SWEA
- 문제해결
- 프로그래머스
- 투포인터
- Java
- 알고리즘
- DP
- 백준
- 이분탐색
- 시뮬레이션
- priorityqueue
- 건강
- oracle
- 코테
- SQL
- math
- 러닝일지
- MySQL
- dfs
- COS PRO
- 문제풀이
- BFS
Archives
- Today
- Total
슈콩
[프로그래머스] Lv.2 택배상자 본문



[문제]
https://school.programmers.co.kr/learn/courses/30/lessons/131704
프로그래머스
SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
[소스 코드]
import java.util.*;
class Solution {
public int solution(int[] order) {
int answer = 0;
int n = order.length;
int idx = 0;
Stack<Integer> stack = new Stack<>();
for(int i=1;i<=n;i++){
stack.push(i);
while(!stack.isEmpty() && stack.peek()==order[idx]){
stack.pop();
idx++;
answer++;
}
}
return answer;
}
}'Algorithms > Programmers' 카테고리의 다른 글
| [프로그래머스] Lv.2 숫자 변환하기 (0) | 2025.10.16 |
|---|---|
| [프로그래머스] Lv.2 스킬트리 (0) | 2025.10.16 |
| [프로그래머스] Lv.2 땅따먹기 (0) | 2025.10.16 |
| [프로그래머스] Lv.2 주식가격 (0) | 2025.10.16 |
| [프로그래머스] Lv.2 더 맵게 (0) | 2025.10.16 |