diff --git a/jung0115/README.md b/jung0115/README.md index a1c227c..6c71072 100644 --- a/jung0115/README.md +++ b/jung0115/README.md @@ -25,4 +25,6 @@ | 21차시 | 2024.10.23.수 | DFS | [여행경로(Lv.2)](https://school.programmers.co.kr/learn/courses/30/lessons/43164) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/181 | | 22차시 | 2024.10.30.수 | 브루트포스 | [점 찍기(Lv.2)](https://school.programmers.co.kr/learn/courses/30/lessons/140107) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/182 | | 23차시 | 2024.11.02.토 | 그리디 알고리즘 | [구명보트(Lv.2)](https://school.programmers.co.kr/learn/courses/30/lessons/42885) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/184 | -| 24처사 | 2024.11.09.토 | 그리디 알고리즘 | [섬 연결하기(Lv.3)](https://school.programmers.co.kr/learn/courses/30/lessons/42861) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/187 | \ No newline at end of file +| 24차시 | 2024.11.09.토 | 그리디 알고리즘 | [섬 연결하기(Lv.3)](https://school.programmers.co.kr/learn/courses/30/lessons/42861) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/187 | +| 25차시 | 2024.11.27.수 | 그리디 알고리즘 | [호텔 대실(Lv.2)](https://school.programmers.co.kr/learn/courses/30/lessons/155651) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/189 | +| 26차시 | 2024.12.02.월 | 수학 | [시소 짝꿍(Lv.2)](https://school.programmers.co.kr/learn/courses/30/lessons/152996) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/190 | \ No newline at end of file diff --git "a/jung0115/\352\267\270\353\246\254\353\224\224\354\225\214\352\263\240\353\246\254\354\246\230/Programmers_155651.kt" "b/jung0115/\352\267\270\353\246\254\353\224\224\354\225\214\352\263\240\353\246\254\354\246\230/Programmers_155651.kt" new file mode 100644 index 0000000..246ee9e --- /dev/null +++ "b/jung0115/\352\267\270\353\246\254\353\224\224\354\225\214\352\263\240\353\246\254\354\246\230/Programmers_155651.kt" @@ -0,0 +1,19 @@ +// 25차시 2024.11.27.수 : 프로그래머스 - 호텔 대실(Lv.2) +import java.util.Arrays + +class Solution { + fun solution(book_time: Array>): Int { + val times = IntArray(1440) + + for (time in book_time) { + var start = time[0].substring(0, 2).toInt() * 60 + time[0].substring(3, 5).toInt() + var end = time[1].substring(0, 2).toInt() * 60 + time[1].substring(3, 5).toInt() + + for (j in start until (end + 10).coerceAtMost(1440)) { + times[j]++ + } + } + + return times.maxOrNull() ?: 0 + } +} \ No newline at end of file diff --git "a/jung0115/\352\267\270\353\246\254\353\224\224\354\225\214\352\263\240\353\246\254\354\246\230/Programmers_42861.py" "b/jung0115/\352\267\270\353\246\254\353\224\224\354\225\214\352\263\240\353\246\254\354\246\230/Programmers_42861.py" index 2f42887..f9eafd5 100644 --- "a/jung0115/\352\267\270\353\246\254\353\224\224\354\225\214\352\263\240\353\246\254\354\246\230/Programmers_42861.py" +++ "b/jung0115/\352\267\270\353\246\254\353\224\224\354\225\214\352\263\240\353\246\254\354\246\230/Programmers_42861.py" @@ -1,4 +1,4 @@ -# 프로그래머스 - 섬 연결하기(Lv.3) +# 24차시 2024.11.09.토 : 프로그래머스 - 섬 연결하기(Lv.3) def solution(n, costs): answer = 0 diff --git "a/jung0115/\354\210\230\355\225\231/Programmers_152996.kt" "b/jung0115/\354\210\230\355\225\231/Programmers_152996.kt" new file mode 100644 index 0000000..3f2cbd5 --- /dev/null +++ "b/jung0115/\354\210\230\355\225\231/Programmers_152996.kt" @@ -0,0 +1,35 @@ +// 26차시 2024.12.02.월 : 프로그래머스 - 시소 짝꿍(Lv.2) +class Solution { + fun solution(weights: IntArray): Long { + var answer: Long = 0 + val weightCount = mutableMapOf() + + for(weight in weights) { + weightCount[weight] = weightCount.getOrDefault(weight, 0L) + 1 + } + + for((weight, count) in weightCount) { + // 같은 무게인 사람이 2명 이상 -> 1:1로 앉을 수 있음 + if(count > 1) { + answer += count * (count - 1) / 2 + } + + // 2:3 비율 + if (weight % 2 == 0 && weightCount.containsKey(weight * 3 / 2)) { + answer += count * weightCount[weight * 3 / 2]!! + } + + // 2:4 = 1:2 비율 + if (weightCount.containsKey(weight * 2)) { + answer += count * weightCount[weight * 2]!! + } + + // 3:4 비율 + if (weight % 3 == 0 && weightCount.containsKey(weight * 4 / 3)) { + answer += count * weightCount[weight * 4 / 3]!! + } + } + + return answer + } +} \ No newline at end of file