Day72

강태훈·2026년 4월 14일

nbcamp TIL

목록 보기
72/97

알고리즘 코드카타

Students and Examinations

with student_exam as (
    select a.student_id, a.student_name, b.subject_name
    from students a
    join Subjects b
)

select a.student_id, a.student_name, a.subject_name, count(b.subject_name) as attended_exams 
from student_exam a
left join Examinations b
on a.subject_name = b.subject_name
and a.student_id = b.student_id
group by a.student_id, a.subject_name
order by a.student_id asc, a.subject_name asc
; 

덧칠하기

class Solution {
    public int solution(int n, int m, int[] section) {

        if(m==0){
            return 0;
        }

        int answer = 0;
//        int sum = section[section.length-1] - section[0] + 1;
//
//        answer = sum / m;
//        if(sum%m != 0){
//            answer++;
//        } // 틀렸는데 반례 찾는게 힘들었다
        int result = section[0] - 1;
        for (int i = 0; i < section.length; i++) {
            if (section[i] > result){
                answer++;
                result = section[i] + m - 1;
            }
        }

        return answer;
    }
}

0개의 댓글