일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- Java
- 포인트 컷
- replace()
- 스프링 다중프로필
- map
- 백준 1967번 트리의 지름 G4 자바
- StringTokenizer
- append
- hash
- 서브모듈 yml
- 코틀린기초
- 전위 중위 후위
- 백준 1240번 노드사이의 거리
- HashMap
- 프로그래머스
- 프로그래머스 자바
- 백준 2589번 보물섬 G5
- 백준 2206번 벽 부수고 이동하기 G3
- toUpperCase
- 프로그래머스 java
- kotlin
- dp
- 백준 11725번 트리의 부모 찾기
- 백준 1600번 말이 되고픈 원숭이
- 백준 8979번 올림픽 S5 자바
- 스프링 on-profile
- HashSet
- Stack
- 백준 2660번 회장뽑기 G5
- StringBuilder
Archives
- Today
- Total
말하는 컴공감자의 텃밭
프로그래머스 [PCCE 기출문제] Lv1. 1, 9번 - 자바 본문
728x90
상하좌우 체크하는 간단한 문제다.
public static int [] dh = {0, 1, -1, 0};
public static int [] dw = {1, 0, 0, -1};
범위 체크하고 색이 같은지 확인해서 근처에 같은 색이라면 answer ++ 해주는 문제다.
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 | class Solution { public static int [] dh = {0, 1, -1, 0}; public static int [] dw = {1, 0, 0, -1}; public int solution(String[][] board, int h, int w) { int answer = 0; String now_col = board[h][w]; int n = board.length; for(int i = 0; i<4; i++){ int cur_h = h + dh[i]; int cur_w = w + dw[i]; if(cur_h >= 0 && cur_w >= 0 && cur_w < n && cur_h < n ){ if(board[cur_h][cur_w].equals(now_col)){ answer++; } } } return answer; } } | cs |
간단쓰
붕대 감기도 간단한 구현 문제쓰..
문제만 잘 읽어서 풀면 간단합니다.
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 32 33 34 35 36 37 38 39 40 41 42 43 | class Solution { public int solution(int[] bandage, int health, int[][] attacks) { int time = 0; int idx = 0; int combo = 0; int heal = bandage[1]; int health_max = health; while(idx < attacks.length){ int att_time = attacks[idx][0]; int att_damage = attacks[idx][1]; if(time == att_time){ health -= att_damage; combo = 0; idx ++; }else{ health += heal; combo ++; } if( combo == bandage[0]){ combo = 0; health += bandage[2]; } if(health > health_max){ health = health_max; } if(health <= 0){ health = -1; break; } time ++; } return health; } } | cs |
lv.0 정리
https://hb-in99.tistory.com/99
프로그래머스 PCCE 기출문제 Lv.0 모음 - 자바
프로그래머스를 안푼지 꽤 됐는데 새로운 유형의 문제가 나와서 흥미가 갔다. PCCE는 Programmers Certified Coding Essential 로 프로그래머스 코딩필수역량인증 시험프로그래밍 문법과 알고리즘에 대한
hb-in99.tistory.com
728x90
'알고리즘 > Programmers - Java' 카테고리의 다른 글
프로그래머스 PCCE 기출문제 Lv.0 모음 - 자바 (0) | 2023.12.16 |
---|---|
프로그래머스 - 뒤에 있는 큰 수 찾기 <9점> - 자바 java Stack (0) | 2023.08.04 |
프로그래머스 카드 뭉치 <1점> - 자바(java) (0) | 2023.07.10 |
프로그래머스 귤 고르기 <2점> - 자바(java) HashMap (0) | 2023.07.06 |
프로그래머스 [1차] 비밀지도 <1점> - 자바(java) (0) | 2023.07.05 |
Comments