f '레벨3' 태그의 글 목록 — 하늘속에서IT

레벨3

    Programmers :: 고득점 kit :: 이중우선순위큐

    풀이 class 이중우선순위큐 { /** * 설명 * - 정렬 된다면 가장 큰 값과 가장 작은 값을 인덱스로 찾아 낼 수 있다. * - 따라서 정렬을 시킨 뒤에 해당 원소를 삭제 시킴으로써 해결할 수 있다. * */ fun solution(operations: Array): IntArray { val sortedList = mutableListOf() operations.forEach { operation -> if(operation.contains("I")){ sortedList.add(operation.split(" ")[1].toInt()) sortedList.sort() } else{ if(sortedList.isNotEmpty()){ if(operation == "D 1"){ sortedList..

    Programmers 동적계획법 :: 레벨3 :: N 으로 표현

    풀이 /** * 설명 * - 프로그래머스 > 고득점 kit > 동적계획법 > level3 > N으로 표현 * - 경로 : https://school.programmers.co.kr/learn/courses/30/lessons/42895?language=kotlin * * */ class ExpressedByN { fun solution(N: Int, number: Int): Int{ // 초기 접근 // var answer = 0 // // if(N == number){ // return 1; // } // // val oneTimesUsed = listOf(5) // val twoTimesUsed = listOf(55, 5+5, 5-5, 5*5, 5/5) // val threeTimesUsed = li..

    Programmers :: DFS(깊이 우선 탐색법) 네트워크 레벨 3

    풀이 import java.util.* class Solution { fun solution(n: Int, computers: Array): Int { val graph = Graph(n, computers) graph.buildEdge( graph.computersToRelationList() ) return graph.getNetworkSize() } } class Graph(n: Int, computers: Array) { val N: Int = n val adj = Array(N) { LinkedList() } val computers = computers fun buildEdge(relationList: List) { relationList.forEach { relation -> this.adj..