[프로그래머스] Lv.2 전력망을 둘로 나누기
·
Algorithm/프로그래머스
https://school.programmers.co.kr/learn/courses/30/lessons/86971 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 사용 알고리즘완전 탐색그래프 탐색BFS풀이 import java.util.*;class Solution { static List> graph = new ArrayList(); static boolean[] visited; static int min = Integer.MAX_VALUE; public int solution(int n, int[][] wires) { in..
[프로그래머스] Lv.3 베스트 앨범
·
Algorithm/프로그래머스
사용 알고리즘해쉬 풀이 기존에 제출해서 틀린 풀이import java.util.*;class Solution { // 1. 장르의 플레이 타임 총합을 맵에 담아서 많이 재생된 순서로 정렬한다. public int[] solution(String[] genres, int[] plays) { Map genreMap = new HashMap(); Map indexMap = new HashMap(); for(int i = 0; i totalPlays = new ArrayList(genreMap.values()); Collections.sort(totalPlays, Collections.reverseOrder..
[프로그래머스] Lv.3 네트워크
·
Algorithm/프로그래머스
https://school.programmers.co.kr/learn/courses/30/lessons/43162 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 사용 알고리즘그래프 탐색BFS풀이 import java.util.*;class Solution { static List> graph = new ArrayList(); static boolean [] visited; static int answer = 0; public int solution(int n, int[][] computers) { for(int..
[프로그래머스] Lv.2 피로도
·
Algorithm/프로그래머스
https://school.programmers.co.kr/learn/courses/30/lessons/87946 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 사용 알고리즘DFS백트래킹풀이class Solution { // current라는 현재값을 static boolean [] visited; static int ans = 0; public int solution(int k, int[][] dungeons) { visited = new boolean[dungeons.length]; dfs(k, dungeon..
[프로그래머스] Lv.2 요격 시스템
·
Algorithm/프로그래머스
https://school.programmers.co.kr/learn/courses/30/lessons/181188 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 사용 알고리즘그리디 알고리즘정렬풀이import java.util.*;class Solution { public int solution(int[][] targets) { int answer = 0; Arrays.sort(targets, (a,b) -> a[1] - b[1]); int before = 0; for(int [] targ..
[프로그래머스] Lv.2 디펜스 게임
·
Algorithm/프로그래머스
https://school.programmers.co.kr/learn/courses/30/lessons/142085 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 이전 제출 답안import java.util.*;class Solution { public int solution(int n, int k, int[] enemy) { int answer = 0; // min = 1, max = 5 mid = 3 // 10만 * int [] tmp = Arrays.copyOf(enemy, enem..