전체 글
-
[프로그래머스] 가장먼노드 - 자바(JAVA)알고리즘/프로그래머스 2022. 6. 16. 00:01
https://programmers.co.kr/learn/courses/30/lessons/49189 코딩테스트 연습 - 가장 먼 노드 6 [[3, 6], [4, 3], [3, 2], [1, 3], [1, 2], [2, 4], [5, 2]] 3 programmers.co.kr 문제 해석 1번부터 n번까지의 노드가 있는 그래프가 존재합니다. 양방향 그래프를 가지며 간선의 weight는 모두 1으로 볼 수 있습니다. 그리고 1부터 n번까지의 거리를 모두 측정한 뒤 가장 멀리 떨어진 노드가 몇 개인지 찾아야 합니다. 문제 풀이 전 설계 1번을 출발지로 가지며 n번까지의 거리를 모두 최단거리로 구해야 합니다. 바로 다익스트라 알고리즘이 떠올랐기 때문에 다익스트라로 해결해보고자 합니다. 다익스트라에 대해 모르신다..
-
[백준] 10815번 : 숫자 카드 - 자바(JAVA)알고리즘/백준 2022. 6. 15. 00:01
문제 해석 int형 범위내의 N개의 숫자가 주어집니다. 이때 M개의 숫자가 다시 주어지고 M개의 숫자가 N개의 숫자에 존재하는지 탐색하는 문제입니다. 문제 풀이 전 설계 N제한이 50만이기 때문에 O(N^2)은 불가능합니다. 또한 문제에서는 정렬/이분 탐색으로 문제를 해결하라고 제시했지만 더 효율적인 방법인 HashSet을 이용하면 O(1)의 시간복잡도로 해결이 가능할 것 같습니다. 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main_10815_숫자카드 { public static void main(String[] ar..
-
AWS EC2에 스프링부트 프로젝트 배포하기프로젝트/게시판 프로젝트 2022. 6. 14. 02:38
AWS 가입 및 EC2 인스턴스 생성(1) EC2 자바 11 설치 및 타임존 설정(2) AWS RDS 구축하기(3) AWS EC2에 스프링부트 프로젝트 배포하기(4) 현재 RDS와 EC2를 모두 구축해 놓은 상황입니다. 깃허브에서 코드를 받아올 수 있게 EC2에 Git을 설치합니다. 1. putty를 통해 EC2에 접속하여 git --version 명령어를 입력합니다. 현재 git이 설치되어 있지 않습니다. 2. sudo yum install git 명령어로 git 설치 이제 git이 설치되었습니다. 3. git clone으로 프로젝트를 저장할 디렉터리 생성 mkdir ~/app && mkdir ~/app/step1 ls 명령어로 디렉토리가 잘 생성되었는지 확인할 수 있습니다. 만약 잘못 생성해서 다시 ..
-
[백준] 1644번 : 소수의 연속합 - 자바(JAVA)알고리즘/백준 2022. 6. 14. 00:01
https://www.acmicpc.net/problem/1644 1644번: 소수의 연속합 첫째 줄에 자연수 N이 주어진다. (1 ≤ N ≤ 4,000,000) www.acmicpc.net 문제 해석 어떤 수 N을 소수의 합으로 나타낼 수 있다면 그 경우의 수를 구하는 문제입니다. 예를 들어보겠습니다. 3은 3 자기 자신으로 한 가지가 가능합니다. 41 = 2 + 3 + 5 + 7 + 11 + 13 , 11 + 13 + 17, 41으로 3가지가 가능합니다. 53 = 5+7+11+13+17 = 53으로 세 가지가 가능합니다. 소수를 모두 구한 다음에 해당 소수를 기반으로 투 포인터를 통해 경우의 수를 탐색하면 될 것 같습니다. 즉, 소수들의 연속된 부분합이 특정수를 만족하는 경우를 찾으면 됩니다. 문제 ..
-
[프로그래머스] 2020 카카오 인턴십 - 경주로 건설 - 자바(JAVA)알고리즘/프로그래머스 2022. 6. 13. 00:01
https://programmers.co.kr/learn/courses/30/lessons/67259 코딩테스트 연습 - 경주로 건설 [[0,0,0,0,0,0,0,1],[0,0,0,0,0,0,0,0],[0,0,0,0,0,1,0,0],[0,0,0,0,1,0,0,0],[0,0,0,1,0,0,0,1],[0,0,1,0,0,0,1,0],[0,1,0,0,0,1,0,0],[1,0,0,0,0,0,0,0]] 3800 [[0,0,1,0],[0,0,0,0],[0,1,0,1],[1,0,0,0]] 2100 [[0,0,0,0,0,0],[0,1,1,1,1,0],[0,0,1,0,0,0],[1,0,0,1,0,1],[ programmers.co.kr 문제 해석 경주로는 N x N 크기의 정사각형 격자형 태이며 각 격자의 크기는 1 x ..
-
[백준] 2957번 : 이진 탐색 트리 - 자바(JAVA)알고리즘/백준 2022. 6. 12. 00:01
https://www.acmicpc.net/problem/2957 2957번: 이진 탐색 트리 이진 탐색 트리는 모든 노드가 많아야 2개의 자식 노드를 가지고 있는 트리이고, 각 노드에는 수가 하나씩 쓰여있다. 만약 어떤 노드에 쓰여 있는 수가 X라면, 그 노드의 왼쪽 서브트리에는 X보다 www.acmicpc.net 문제 해석 1보다 크거나 같고, N보다 작거나 같은 수 N개가 한 번씩 등장하는 수열이 주어집니다. 이때 이진트리를 구성하면 왼쪽 서브트리에는서브 트리에는 X보다 작은 수, 오른쪽 서브 트리에는 X보다 큰 수만 저장되어 있어야 합니다. 첫 번째 수를 루트로 놓고 다 머지 수들을 순서대로 삽입하고자 합니다. 이때 함수안에 C라는 카운터를 1씩 증가시키는 구문이 존재하는데 트리에 삽입된 후에 카..
-
2022 카카오 채용연계형 서머 인턴십 면접 탈락 후기회고 2022. 6. 11. 22:53
서류 및 코딩 테스트 예전에 프로젝트를 수행한 적은 있지만 해당 프로젝트에 대해 깊이 알지 못하였고 다루었던 언어도 python이었기 때문에 따로 기술하진 않았습니다. 가장 최근에 진행했던 Java, Spring, MySQL, JPA를 활용한 프로젝트와 기술블로그를 첨부하였습니다. 현재는 Java 위주로 학습을 하고 있으며 꾸준하게 공부하고 있음을 어필하였습니다. 코딩 테스트는 5문제중 3.5문제를 풀었으며 예전에는 백준 실버문제도 어려웠지만 5개월간 꾸준히 문제를 풀었고 운이 좋게 아는 문제가 나와서 좋은결과가 나왔던 것 같습니다. 프로그래머스 링크 https://school.programmers.co.kr/learn/challenges?order=recent&page=1&partIds=31236 코딩..
-
[백준] 23807번 : 두 단계 최단 경로3 - 자바(JAVA)알고리즘/백준 2022. 6. 11. 00:01
https://www.acmicpc.net/problem/23807 23807번: 두 단계 최단 경로 3 첫째 줄에 정점의 수 N(10 ≤ N ≤ 100,000), 간선의 수 M(10 ≤ M ≤ 300,000)이 주어진다. 다음 M개 줄에 간선 정보 u v w가 주어지며 도시 u와 도시 v 사이의 가중치가 정수 w인 양방향 도로를 나타낸 www.acmicpc.net 문제 해석 시작점과 목적지의 최단거리를 구하는 문제이기 때문에 다익스트라가 바로 떠올랐습니다. 하지만 중간에 꼭 거쳐가야 하는 노드들이 주어집니다. 임의의 P개의 정점중에 적어도 3개의 정점은 무조건 거쳐가야 함. 문제 풀이 전 설계 DP를 사용해야 하나..? 전혀 방법이 떠오르지 않았습니다. 따라서 완전 탐색으로 접근해 보려고 합니다. 1번..