[알고리즘문제풀기] 피자 나눠 먹기

silver's avatar
Nov 24, 2024
[알고리즘문제풀기] 피자 나눠 먹기
 

문제

내가 작성한 정답

class Solution { public int solution(int slice, int n) { int answer = 0; if(n % slice == 0){ answer = n/slice; }else { answer = n/slice + 1; } return answer; } }
 

다른 사람들이 작성한 정답

class Solution { public int solution(int slice, int n) { return n % slice > 0 ? n/slice+1 : n/slice; } }
class Solution { public int solution(int slice, int n) { return (n+slice-1)/slice; } }
Share article

silver