알고리즘/프로그래머스

    네트워크

    https://school.programmers.co.kr/learn/courses/30/lessons/43162 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드 class Solution { int computer[][]; boolean visited[]; public int solution(int n, int[][] computers) { int answer = 0; computer = computers; visited = new boolean[n]; for (int i = 0; i < n; i++) { if(!visited[i]) { answ..

    게임 맵 최단거리

    https://school.programmers.co.kr/learn/courses/30/lessons/1844 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드 import java.util.ArrayDeque; public class Solution { class Node { int r, c; public Node(int r, int c) { this.r = r; this.c = c; } } int[] rx = new int[]{0, 0, -1, 1}; int[] ry = new int[]{-1, 1, 0, 0}; public int soluti..

    입국심사

    https://school.programmers.co.kr/learn/courses/30/lessons/43238#qna 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 틀린 소스코드 import java.util.*; class Solution { public long solution(int n, int[] times) { long answer = 0; TreeMap map = new TreeMap(); for (int time : times) map.put((long)time, (long)time); for (int i = 0; i < n - 1; i+..

    오픈채팅방

    https://school.programmers.co.kr/learn/courses/30/lessons/42888 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드 import java.util.*; class Solution { public String[] solution(String[] record) { HashMap map = new HashMap(); List list = new ArrayList(); List resultList = new ArrayList(); for(String str : record) { String[] strs = s..

    디펜스 게임

    https://school.programmers.co.kr/learn/courses/30/lessons/142085 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드 import java.util.PriorityQueue; import java.util.Collections; class Solution { public int solution(int n, int k, int[] enemy) { int answer = 0; PriorityQueue pq = new PriorityQueue(Collections.reverseOrder()); for (in..

    뒤에 있는 큰 수 찾기

    https://school.programmers.co.kr/learn/courses/30/lessons/154539 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드 import java.util.Stack; class Solution { class Node { int v,o; public Node(int v, int o) { this.v = v; //값 this.o = o; //순서 } } public int[] solution(int[] numbers) { int[] answer = new int[numbers.length]; Stack s = ..

    롤케이크 자르기

    https://school.programmers.co.kr/learn/courses/30/lessons/132265 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드 import java.util.HashSet; class Solution { public int solution(int[] topping) { int answer = 0; HashSet set = new HashSet(); int arr1[] = new int[topping.length]; int arr2[] = new int[topping.length]; for (int i = 0; ..

    행렬과 연산

    https://school.programmers.co.kr/learn/courses/30/lessons/118670 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드 import java.util.*; class Solution { public int[][] solution(int[][] rc, String[] operations) { int[][] answer = rc; Deque left = new ArrayDeque(); Deque right = new ArrayDeque(); Deque mid = new ArrayDeque(); for (in..