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


[소스 코드]
import java.util.*;
class Main {
public int[] solution(String commands) {
int[] answer = new int[2];
for(int i=0;i<commands.length();i++){
if(commands.charAt(i)=='L') answer[0]--;
else if(commands.charAt(i)=='R') answer[0]++;
else if(commands.charAt(i)=='U') answer[1]++;
else answer[1]--;
}
return answer;
}
}