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
- dfs
- 문제풀이
- 알고리즘
- SQL
- 이분탐색
- math
- 시뮬레이션
- DP
- 코딩테스트
- db
- Java
- BFS
- SWEA
- binary search
- BOJ
- greedy
- 문자열
- oracle
- 자바
- 러닝일지
- priorityqueue
- 코테
- 운동기록
- 투포인터
- 프로그래머스
- 문제해결
- 건강
- COS PRO
- MySQL
- 백준
Archives
- Today
- Total
슈콩
[SWEA] 10일차 - 비밀번호 본문


[문제]
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14_DEKAJcCFAYD
[소스 코드]
import java.util.*;
import java.io.*;
public class Solution {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
for(int tc=1;tc<=10;tc++) {
StringBuilder sb = new StringBuilder();
st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
String s = st.nextToken();
Deque<Character> dq = new LinkedList<>();
for(int i=0;i<n;i++) {
char c = s.charAt(i);
if(!dq.isEmpty() && dq.peekLast()==c) {
dq.pollLast();
}
else {
dq.offerLast(c);
}
}
for(char c : dq) {
sb.append(c);
}
System.out.println("#"+tc+" "+sb);
}
}
}'Algorithms > SWEA' 카테고리의 다른 글
| [SWEA] 정곤이의 단조 증가하는 수 (0) | 2025.11.11 |
|---|---|
| [SWEA] 교환학생 (0) | 2025.11.11 |
| [SWEA] 규영이와 인영이의 카드게임 (0) | 2025.11.10 |
| [SWEA] 3일차 - String (0) | 2025.11.10 |
| [SWEA] 0/1 Knapsack (0) | 2025.11.10 |