본문 바로가기

전체 글

(120)
[프로그래머스] 2 X N 타일링 / JAVA 문제링크 : https://programmers.co.kr/learn/courses/30/lessons/12900 코딩테스트 연습 - 2 x n 타일링 가로 길이가 2이고 세로의 길이가 1인 직사각형모양의 타일이 있습니다. 이 직사각형 타일을 이용하여 세로의 길이가 2이고 가로의 길이가 n인 바닥을 가득 채우려고 합니다. 타일을 채울 때는 programmers.co.kr class Solution { public static int dp[]; public int solution(int n) { int answer = 0; dp = new int[600001]; dp[1] = 1; dp[2] = 2; dp[3] = 3; dp[4] = 5; for(int i=5;i
[프로그래머스] GPS / JAVA 문제링크 : https://programmers.co.kr/learn/courses/30/lessons/1837 import java.util.*; import java.io.*; class Solution { public int solution(int n, int m, int[][] edge_list, int k, int[] gps_log) { //초기화 int answer = 987654321; int dp[][] = new int[k][n+1]; //[a][b]: a번째 목적지에 b가 왔을 때 다른 최소 횟수 List li[] = new List[n+1]; for(int i=1;i
[프로그래머스] 불량 사용자 / JAVA 문제링크 : https://programmers.co.kr/learn/courses/30/lessons/64064 코딩테스트 연습 - 불량 사용자 개발팀 내에서 이벤트 개발을 담당하고 있는 "무지"는 최근 진행된 카카오이모티콘 이벤트에 비정상적인 방법으로 당첨을 시도한 응모자들을 발견하였습니다. 이런 응모자들을 따로 모아 불량 programmers.co.kr class Solution { public static boolean visited[]; public static boolean bitmask[]; public static int ans; public static String g_banned_id[]; public static String g_user_id[]; public static boolea..
[프로그래머스] 보석 쇼핑 / JAVA 문제링크 : https://programmers.co.kr/learn/courses/30/lessons/67258 코딩테스트 연습 - 보석 쇼핑 ["DIA", "RUBY", "RUBY", "DIA", "DIA", "EMERALD", "SAPPHIRE", "DIA"] [3, 7] programmers.co.kr import java.util.*; class Solution { public static int[] solution(String[] gems) { int[] answer = new int[2]; HashSet hs = new HashSet(); for(int i=0;i newLen){ len = newLen; answer[0] = left+1; answer[1] = right; } String e..
[프로그래머스] 순위 / JAVA 문제링크 : https://programmers.co.kr/learn/courses/30/lessons/49191 코딩테스트 연습 - 순위 5 [[4, 3], [4, 2], [3, 2], [1, 2], [2, 5]] 2 programmers.co.kr class Solution { public static int solution(int n, int[][] results) { int answer = 0; boolean isConnected[][] = new boolean[n+1][n+1]; for(int i=0;i
[프로그래머스] 네트워크 / JAVA 문제링크 : https://programmers.co.kr/learn/courses/30/lessons/43162 코딩테스트 연습 - 네트워크 네트워크란 컴퓨터 상호 간에 정보를 교환할 수 있도록 연결된 형태를 의미합니다. 예를 들어, 컴퓨터 A와 컴퓨터 B가 직접적으로 연결되어있고, 컴퓨터 B와 컴퓨터 C가 직접적으로 연결되어 있 programmers.co.kr import java.util.*; class Solution { public static int par[]; public static int find(int x){ if(par[x] == x) return x; return par[x] = find(par[x]); } public static void union(int x, int y){ in..
[프로그래머스] 정수 삼각형 / JAVA 문제링크 : https://programmers.co.kr/learn/courses/30/lessons/43105 class Solution { public static int dp[][]; public static int triangles[][]; public static int dfs(int y,int x){ if(y==triangles.length-1) return dp[y][x] = triangles[y][x]; if(dp[y][x] != -1) return dp[y][x]; return dp[y][x] = Math.max(dfs(y+1,x),dfs(y+1,x+1)) + triangles[y][x]; } public static int solution(int[][] triangle) { int a..
[프로그래머스] 디스크 컨트롤러 / JAVA 문제링크 : https://programmers.co.kr/learn/courses/30/lessons/42627 코딩테스트 연습 - 디스크 컨트롤러 하드디스크는 한 번에 하나의 작업만 수행할 수 있습니다. 디스크 컨트롤러를 구현하는 방법은 여러 가지가 있습니다. 가장 일반적인 방법은 요청이 들어온 순서대로 처리하는 것입니다. 예를 programmers.co.kr import java.util.*; class Solution { public static class Node{ int startTime; int cost; } public static int solution(int[][] jobs) { int answer = 0; int N = jobs.length; PriorityQueue pq = new ..