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

[문제]
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AZVqPrHaAy_HBIOy
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
[소스 코드]
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine());
for(int tc=1;tc<=T;tc++) {
String str = br.readLine();
int disL = check(str,"L");
int disR = check(str,"R");
System.out.println("#"+tc+" "+Math.max(disL, disR));
}
}
private static int check(String str,String d) {
String make = str.replace("?", d);
int result = 0;
int max = 0;
for(int i=0;i<make.length();i++) {
if(make.charAt(i)=='L') result--;
else result++;
max = Math.max(max, Math.abs(result));
}
return max;
}
}'Algorithms > SWEA' 카테고리의 다른 글
| [SWEA] 평범한 숫자 (0) | 2025.11.18 |
|---|---|
| [SWEA] 색상환 (0) | 2025.11.18 |
| [SWEA] 승률 비교하기 (0) | 2025.11.18 |
| [SWEA] 세상의 모든 팰린드롬 2 (0) | 2025.11.18 |
| [SWEA] 테네스의 특별한 소수 (0) | 2025.11.18 |