Programmers Practice
-
경주로 건설 (with Kotlin)Programmers Practice/level 3 2025. 8. 20. 15:58
https://school.programmers.co.kr/learn/courses/30/lessons/67259 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.krimport java.util.PriorityQueueconst val L = 0const val R = 1const val U = 2const val D = 3fun Int.equalDir(d: Int): Boolean { if (this == d) return true if (this in listOf(0, 1)) return d in listOf(0, 1) if (this in listOf(2, 3)) return d in listO..
-
길 찾기 게임 (with Kotlin)Programmers Practice/level 3 2025. 8. 11. 16:11
https://school.programmers.co.kr/learn/courses/30/lessons/42892 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.krfilterNot 메서드를 이용해서 불변 리스트에서 특정 값을 제거한 레퍼런스를 새롭게 만든다.data class Node( val index: Int, val x: Int, val y: Int)data class Tree( val root: Node, var left: Tree? = null, var right: Tree? = null)class Solution { fun solution(nodeinfo: Array..
-
디스크 컨트롤러 (with Kotlin)Programmers Practice/level 3 2025. 8. 1. 18:14
https://school.programmers.co.kr/learn/courses/30/lessons/42627 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.krLinkedList를 이용하여 첫 번째 요소를 제거하는 부분의 시간을 최소화한다. 크기가 작기 때문에 별 차이는 없다.import java.util.LinkedListimport java.util.PriorityQueuedata class Data( val s: Int, val t: Int,)class Solution { fun solution(jobs: Array): Int { val result = mutableListOf..
-
부대 복귀 (with Kotlin)Programmers Practice/level 3 2025. 7. 17. 14:13
https://school.programmers.co.kr/learn/courses/30/lessons/132266 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr import java.util.PriorityQueuedata class Node( val i: Int, val distance: Int)class Solution { fun solution(n: Int, roads: Array, sources: IntArray, destination: Int): IntArray { var answer: IntArray = intArrayOf() val graph..
-
미로 탈출 명령어 (with Kotlin)Programmers Practice/level 3 2025. 7. 16. 17:47
https://school.programmers.co.kr/learn/courses/30/lessons/150365 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.krdfs를 stack 자료구조를 이용해서 스택 메모리에서 처리되는 것처럼 구현함. 원래의 메서드에서 리턴 값은 파라미터로 전달하여 최종적으로 필요한 경우에는 리턴할 수 있도록 처리한다.import kotlin.math.absdata class Element( val r: Int, val c: Int)data class Param( val r: Int, val c: Int, val path: String, val k: Int..
-
매칭 점수 (with Kotlin)Programmers Practice/level 3 2025. 7. 14. 16:22
https://school.programmers.co.kr/learn/courses/30/lessons/42893 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.krRegex에서 group을 이용해서 html 특정 요소를 얻어내고 복잡한 경우에는 Regex와 String method를 같이 활용한다. maxByOrNull메서드를 이용해서 최댓값이 있는 경우 그 값을 가지는 요소를 리턴하도록 한다. (maxOf는 가장 큰 값을 리턴한다)data class Site( val url: String, val hyperUrls: List, val matchingCount: Int)class Solution {..
-
코딩 테스트 공부 (with Kotlin)Programmers Practice/level 3 2025. 7. 11. 13:00
https://school.programmers.co.kr/learn/courses/30/lessons/118668/ 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.krconst val MAX = 152class Solution { fun solution(alp: Int, cop: Int, problems: Array): Int { val dp = Array(MAX) { IntArray(MAX) { Int.MAX_VALUE } }.apply { this[alp][cop] = 0 } val maxAlp = maxOf(alp, problem..
-
상담원 인원 (with Kotlin)Programmers Practice/level 3 2025. 7. 9. 20:04
https://school.programmers.co.kr/learn/courses/30/lessons/214288 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.krimport java.util.PriorityQueueimport kotlin.math.maxclass Solution { fun combination(n: Int, r: Int): List> { fun dfs(start: Int, path: MutableList): List> { if (path.size == r) { return listOf(path.toList()) ..