문제 링크
[level 0] 피자 나눠 먹기 (3) - 120816
Note
조건이 true이면 실행을 반복하는 while 문을 사용함.
피자 나눠 먹기 시리즈 중 가장 간단하다고 생각됨.
Key
- while 문
제출한 코드
class Solution {
public int solution(int slice, int n) {
int answer = 1;
while(slice * answer < n){
answer++;
}
return answer;
}
}
반응형
'코딩테스트 > Java' 카테고리의 다른 글
프로그래머스/자바 lv1. 가운데 글자 가져오기 - substring(), length(), 삼항연산자 (0) | 2024.03.25 |
---|---|
프로그래머스/자바 lv.1 삼총사 - 삼중for문, 완전탐색, 깊이 우선 탐색(DFS) (0) | 2024.03.23 |
프로그래머스/자바 lv.1 서울에서 김서방 찾기 - Arrays.asList().indexOf() (0) | 2024.03.22 |