본문 바로가기

전체 글

(315)
프로그래머스 - 43162번: 네트워크 [Java] 문제: https://school.programmers.co.kr/learn/courses/30/lessons/43162 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 1. 코드 import java.util.*; class Solution { public int solution(int n, int[][] computers) { int answer = 0; boolean[] check = new boolean[n]; for(int i = 0; i < n; i++) { if(check[i]) continue; DFS(n, computers, check, i..
프로그래머스 - 92335번: k진수에서 소수 개수 구하기 [Java] 문제: https://school.programmers.co.kr/learn/courses/30/lessons/92335 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 1. 코드 import java.math.*; class Solution { public int solution(int n, int k) { int answer = 0; StringBuilder sb = new StringBuilder(); while(n > 0) { sb.append(n % k); n /= k; } for(String s : sb.reverse().toString().sp..
프로그래머스 - 42577번: 전화번호 목록 [Java] 문제: https://school.programmers.co.kr/learn/courses/30/lessons/42577 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 1. 코드 import java.util.*; class Solution { public boolean solution(String[] phone_book) { boolean answer = true; Arrays.sort(phone_book); for(int i = 0; i < phone_book.length - 1; i++) { if(phone_book[i].startsWith(phon..
프로그래머스 - 43105번: 정수 삼각형 [Java] 문제: https://school.programmers.co.kr/learn/courses/30/lessons/43105 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr1. 코드class Solution { static int[][] arr; public static int solution(int[][] triangle) { arr = new int[triangle.length][triangle[triangle.length - 1].length]; return DP(triangle, 0, 0); } public static int DP(int[][] trian..
프로그래머스 - 42628번: 이중우선순위 [Java] 문제: https://school.programmers.co.kr/learn/courses/30/lessons/42628 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 1. 코드 import java.util.*; class Solution { public int[] solution(String[] operations) { int[] answer = new int[2]; PriorityQueue min = new PriorityQueue(); PriorityQueue max = new PriorityQueue(Collections.reverseOrder(..
프로그래머스 - 43165번: 타겟 넘버 [Java] 문제: https://school.programmers.co.kr/learn/courses/30/lessons/43165 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 1. 코드 import java.util.*; class Solution { static int answer = 0; public int solution(int[] numbers, int target) { DFS(numbers, target, 0, 0); return answer; } public static void DFS(int[] numbers, int target, int sum, ..
백준 알고리즘 - 4779번: 칸토어 집합 [Java] 실패 문제: https://www.acmicpc.net/problem/4779 4779번: 칸토어 집합 칸토어 집합은 0과 1사이의 실수로 이루어진 집합으로, 구간 [0, 1]에서 시작해서 각 구간을 3등분하여 가운데 구간을 반복적으로 제외하는 방식으로 만든다. 전체 집합이 유한이라고 가정하고, www.acmicpc.net 1. 코드 import java.util.*; public class Main { static char[] arr; public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNextInt()) { repeat(sc.nextInt()); System.out.println(); } } pub..
프로그래머스 - 87946번: 피로도 [Java] 실패 문제: https://school.programmers.co.kr/learn/courses/30/lessons/87946 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 1. 코드 class Solution { static int answer = 0; static boolean[] check; public int solution(int k, int[][] dungeons) { check = new boolean[dungeons.length]; DFS(k, dungeons, 0); return answer; } public void DFS(int k, int..