Day64

강태훈·2026년 4월 2일

nbcamp TIL

목록 보기
64/97

알고리즘 코드카타

Article Views I

select distinct author_id as id
from Views
where author_id = viewer_id
order by author_id asc;

푸드 파이트 대회

class Solution {
    public String solution(int[] food) {
        String answer = "";
        for(int i = 1; i < food.length; i++){
            for(int j = 0; j < food[i]/2; j++){
                answer += Integer.toString(i);
            }
        }
        StringBuilder builder = new StringBuilder(answer);
        answer += "0" + builder.reverse();

        return answer;
    }
}

콜라 문제

class Solution {
    public int solution(int a, int b, int n) {
        int answer = 0;
        int coke = n;
        int last = 0;
        while(true){
            last = coke%a;
            coke /= a;
            answer += coke*b;
            coke = coke*b + last;
            if(coke < a){
                break;
            }
        }
        return answer;
    }
}

0개의 댓글