본문 바로가기

CodingTest/Programmers52

[Programmers] 더 맵게 [문제 링크]https://school.programmers.co.kr/learn/courses/30/lessons/42626 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr [풀이 과정]우선순위큐를 사용하여 배열을 정렬한 후 문제에 맞춰 구현했습니다. [코드]import java.util.*;class Solution { public int solution(int[] scoville, int K) { int answer = 0; PriorityQueue queue = new PriorityQueue(); // 우선순위큐에 배열을 담아 알아서 자동.. 2025. 4. 22.
[Programmers] 단어 변환 [문제 링크]https://school.programmers.co.kr/learn/courses/30/lessons/43163 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr [풀이 과정]bfs를 통해 갈 수 있는 곳을 하나씩 저장하여 방문하면서가장 먼저 target과 같은 문자열이 나오면 각각 count한 숫자를 반환한다. [코드]import java.util.*;// 편하게 String과 int를 넣기 위해 만든 classclass A { String str; int count; public A(String str, int count) { this.str = str.. 2025. 4. 22.
[Programmers] 게임 맵 최단거리 [문제 링크]https://school.programmers.co.kr/learn/courses/30/lessons/1844 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr [풀이 과정] 모든 경우의 수를 bfs알고리즘을 통해 풀었습니다. [코드]import java.util.*;class Solution { int[] dx = {-1, 1, 0, 0}; int[] dy = {0, 0, -1, 1}; int[][] maps; boolean[][] visited; int x; int y; public int solution(int[][] maps) { .. 2025. 4. 21.
[Programmers] 네트워크 [문제 링크]https://school.programmers.co.kr/learn/courses/30/lessons/43162 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr [풀이 과정]기본적인 dfs 문제였습니다. [코드]import java.util.*;class Solution { boolean[] visited; int[][] computers; int n; public int solution(int n, int[][] computers) { visited = new boolean[n]; int answer = 0; this.n.. 2025. 4. 21.
[Programmers] 타겟 넘버 [문제 링크]https://school.programmers.co.kr/learn/courses/30/lessons/43165 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr [풀이 과정]dfs를 사용하여 하나하나 모두 구하여 해결하였습니다. [코드]import java.util.*;class Solution { int answer; int target; int[] numbers; public int solution(int[] numbers, int target) { answer = 0; this.target = target; this.numb.. 2025. 4. 21.
[Programmers] 모음사전 [문제 링크]https://school.programmers.co.kr/learn/courses/30/lessons/84512?language=java 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr [풀이 과정]모든 경우의 수를 다 구하여 사전을 만들고 해당 String 값의 index를 찾아서 답을 구할 생각을 했습니다.사전을 만들때 dfs를 사용하는데 dfs를 사용하면 사전 순으로 자동으로 정렬되기 때문에 굳이 따로 정렬을 하지 않았습니다. [코드]import java.util.*;class Solution { List arr; String[] words; public int.. 2025. 4. 21.