전체 글
-
Docker compose 사용하기MSA & 쿠버네티스(Kubernetes) - k8s 2022. 9. 4. 00:01
Docker Compose 없이 이미지 컨테이너화 아래의 명령어들을 사용하게 되면 wordpress_net이라는 이름의 network를 구성하고 mysql과 wordpress 이미지를 컨테이너화 시킵니다. docker network create wordpress_net docker run --name "db" -e "MYSQL_ROOT_PASSWORD=123456" -e "MYSQL_DATABASE=wordpress" -e "MYSQL_USER=wordpress_user" -e "MYSQL_PASSWORD=123456" --network wordpress_net mysql:5.7 docker run --name app -e "WORDPRESS_DB_HOST=db" -e "WORDPRESS_DB_USER=..
-
[백준] 1107번 : 리모컨 - 자바(JAVA)알고리즘/백준 2022. 9. 3. 00:01
https://www.acmicpc.net/problem/1107 1107번: 리모컨 첫째 줄에 수빈이가 이동하려고 하는 채널 N (0 ≤ N ≤ 500,000)이 주어진다. 둘째 줄에는 고장난 버튼의 개수 M (0 ≤ M ≤ 10)이 주어진다. 고장난 버튼이 있는 경우에는 셋째 줄에는 고장난 버튼 www.acmicpc.net 문제 해석 100번 채널에서 시작하여 +,-버튼을 통해 이동하려고 합니다. 이때 최소로 버튼을 눌러서 N번 채널로 이동하려고 합니다. 고장 난 버튼이 존재하여 고장 난 버튼은 누를 수 없습니다. 문제 풀이 전 설계 최단거리를 구해야 하기 때문에 BFS를 활용해보고자 합니다. 이미 최단거리로 만들어진 채널은 방문할 필요가 없습니다. 100번 채널에서 퍼저나가는 형식으로 시작됩니다. ..
-
[백준] 1676번 : 팩토리얼0의개수 - 자바(JAVA)알고리즘/백준 2022. 9. 2. 00:01
https://www.acmicpc.net/problem/1676 1676번: 팩토리얼 0의 개수 N!에서 뒤에서부터 처음 0이 아닌 숫자가 나올 때까지 0의 개수를 구하는 프로그램을 작성하시오. www.acmicpc.net 문제 해석 N!이 값이 가지는 0의 개수를 구해야 합니다. 만약 N!이 값이 1234000이라고 가정하면 0의 개수는 3개입니다. 문제 풀이 전 설계 1234000을 분리하면 1234 * 1000 으로 분리할 수 있습니다. 이것 또 분리하면 1234 * 10 * 10 * 10 으로 분리할 수 있습니다. 즉, 0의 개수는 10의 개수와 동일합니다. 또한 10은 2 * 5입니다. 결국 우리는 N!의 수가 2^x * 5^y 가 몇 개 나오는지 찾고 Math.min(x, y)를 하면 정답이..
-
[백준] 7662번 : 이중우선순위큐 - 자바(JAVA)알고리즘/백준 2022. 9. 1. 00:01
https://www.acmicpc.net/problem/7662 7662번: 이중 우선순위 큐 입력 데이터는 표준입력을 사용한다. 입력은 T개의 테스트 데이터로 구성된다. 입력의 첫 번째 줄에는 입력 데이터의 수를 나타내는 정수 T가 주어진다. 각 테스트 데이터의 첫째 줄에는 Q에 적 www.acmicpc.net 문제 해석 T : 테스트 케이스 Q : 적용할 연산의 개수(최대 백만개) 연산을 나타내는 문자 D 1 : 최대값을 삭제 연산을 나타내는 문자 D -1 : 최솟값을 삭제 연산을 나타내는 문자 I n : n을 삽입하는 연산 최종적으로 큐의 최댓값 최솟값을 출력, 비어있다면 EMPTY 출력 문제 풀이 전 설계 우선순위 큐를 2개 두어 해결하려고 하였습니다. 관건은 연산이 백만 번 일어나고 remov..
-
[백준] 1697번 : 숨바꼭질 - 자바(JAVA)알고리즘/백준 2022. 8. 31. 00:01
https://www.acmicpc.net/problem/1697 1697번: 숨바꼭질 수빈이는 동생과 숨바꼭질을 하고 있다. 수빈이는 현재 점 N(0 ≤ N ≤ 100,000)에 있고, 동생은 점 K(0 ≤ K ≤ 100,000)에 있다. 수빈이는 걷거나 순간이동을 할 수 있다. 만약, 수빈이의 위치가 X일 www.acmicpc.net 문제 해석 이동할 수 있는 방법은 3가지입니다. 현재 위치에서 -1, 현재 위치에서 +1, 현재 위치에서 *2 이동을 하며 X위치에서 K위치로 도달할 수 있는 최단거리를 구해야 합니다. 문제 풀이 전 설계 최단거리 이기 때문에 BFS를 사용해서 해결하고자 합니다. step을 통해서 몇 번 이동했는지를 관리하고 이미 방문한 곳을 또 방문하는 경우는 최단거리가 아니기 때문에..
-
[백준] 2630번 : 색종이만들기 - 자바(JAVA)알고리즘/백준 2022. 8. 30. 00:01
https://www.acmicpc.net/problem/2630 2630번: 색종이 만들기 첫째 줄에는 전체 종이의 한 변의 길이 N이 주어져 있다. N은 2, 4, 8, 16, 32, 64, 128 중 하나이다. 색종이의 각 가로줄의 정사각형칸들의 색이 윗줄부터 차례로 둘째 줄부터 마지막 줄까지 주어진다. www.acmicpc.net 문제 해석 처음에는 전체크기에서 색종이를 체크하고 그 이후에는 4분할로 나누면서 색종이의 수를 체크합니다. 색종이로 체크하기 위해서는 해당하는 모든 구간이 1또는 0이여야 합니다. 그림을 기준으로 설명하자면 맨 처음에는 8x8 색종이가 구성되는지 확인합니다. 이후에 4분면을 제외한 1,2,3분면은 색종이가 완성되지 않았습니다. 1,2,3분면은 각각 4x4의 색종이로 나뉘..
-
병렬 데이터 처리와 성능Java/모던자바인액션요약 2022. 8. 29. 00:01
개요 자바 7 이전에는 데이터 컬렉션을 병렬로 처리하기 어려웠습니다. 자바 7은 포크/조인 프레임워크 기능을 제공하여 쉽게 병렬화를 수행하며 에러를 최소화할 수 있도록 합니다. 하지만 자바 8의 스트림을 사용하면 순차 스트림을 병렬 스트림으로 자연스럽게 바꿀 수 있습니다. (동기화 문제 , 쓰레드는 몇 개로 지정할지 등을 고민하지 않아도 됩니다.) 하지만 내부 처리과정이 어떻게 이루어지는지 알아야 스트림을 잘못 사용하는 상황을 피할 수 있습니다. 병렬 스트림 parallelStream을 호출하여 병렬 스트림을 만들 수 있습니다. 병렬 스트림이란 각각의 스레드에서 스트림을 처리할 수 있도록 여러 청크로 분할한 스트림입니다. 이때 sequential 메서드를 사용하면 병렬 스트림을 순차 스트림으로 바꿀 수도..
-
[백준] 1620번 : 나는야 포켓몬 마스터 이다솜 - 자바(JAVA)알고리즘/백준 2022. 8. 28. 00:01
https://www.acmicpc.net/problem/1620 1620번: 나는야 포켓몬 마스터 이다솜 첫째 줄에는 도감에 수록되어 있는 포켓몬의 개수 N이랑 내가 맞춰야 하는 문제의 개수 M이 주어져. N과 M은 1보다 크거나 같고, 100,000보다 작거나 같은 자연수인데, 자연수가 뭔지는 알지? 모르면 www.acmicpc.net 문제 해석 N의 범위는 10만입니다. M의 범위도 10만입니다. O(NM)의 경우 100억이기 때문에 2중포문으로는 시간초과가 발생합니다. HashMap을 해결하여 문제를 해결했습니다. 이름을 번호로 가지는 하나의 Map 순서를 기준으로 이름을 가지는 하나의 Map 숫자인지 문자인지 구분하기 위해서는 Character.isDigit 메서드를 활용하여 첫문자가 숫자인지 ..