전체 글
-
[백준] 1062번 : 가르침 - 자바(JAVA)알고리즘/백준 2022. 8. 12. 00:01
https://www.acmicpc.net/problem/1062 1062번: 가르침 첫째 줄에 단어의 개수 N과 K가 주어진다. N은 50보다 작거나 같은 자연수이고, K는 26보다 작거나 같은 자연수 또는 0이다. 둘째 줄부터 N개의 줄에 남극 언어의 단어가 주어진다. 단어는 영어 소문 www.acmicpc.net 문제 해석 학생들은 K개의 글자로만 이루어진 단어만을 읽을 수 있습니다. 어떤 K개의 글자를 가르쳐야 학생들이 읽을 수 있는 단어의 개수가 최대가 될까요? 남극 언어의 모든 단어는 "anta"로 시작하고 "tica"로 끝납니다. 문제 풀이 전 설계 항상 a, n , t, i , c라는 5개의 단어는 꼭 필요합니다. 남극 언어의 모든 단어가 anta, tica가 포함되기 때문입니다. subS..
-
[백준] 5430번 : AC - 자바(JAVA)알고리즘/백준 2022. 8. 11. 00:01
https://www.acmicpc.net/problem/5430 5430번: AC 각 테스트 케이스에 대해서, 입력으로 주어진 정수 배열에 함수를 수행한 결과를 출력한다. 만약, 에러가 발생한 경우에는 error를 출력한다. www.acmicpc.net 문제 해석 두 가지 함수 R(뒤집기)와 D(버리기)가 있습니다. R은 배열에 있는 수의 순서를 뒤집습니다. D는 첫번째 수를 버리는 함수입니다. 첫 번째 줄에는 테스트 케이스의 개수가 주어집니다. (최대 100개) 각 테스트 케이스의 첫째 줄에는 수행할 함수 p 가 주어집니다. (최대 10만 개) 배열에 들어있는 수의 개수 n이 주어집니다. (최대 10만 개) 다음 줄에는 배열의 정보가 주어집니다. 이때 배열이 비어있는데 D를 사용하는 경우에는 에러가 ..
-
람다 표현식Java/모던자바인액션요약 2022. 8. 10. 00:01
람다 표현식이란? 익명 클래스처럼 이름이 없는 함수면서 메서드를 인수로 전달할 수 있습니다. 메서드를 하나의 식으로 표현합니다. 메서드 이름과 반환 값이 없을 수 있기 때문에 '익명 함수'라고 합니다. 람다란? 수학 미적분학에 뿌리를 두고 있으며 함수 추상화에 기반한 계산을 표현하기 위한 수학 논리입니다. 첫번째 함수 x에 3을 넣게 되면 결과로 9가 나올 것을 예상할 수 있습니다. 람다표현식이 없었던 기능들을 새롭게 제공하지는 않지만 간결한 방식으로 코드를 전달할 수 있습니다. 람다 표현식의 예시 기존의 코드 Comparator byWeight = new Comparator() { @Override public int compare(Apple o1, Apple o2) { return o1.getWeig..
-
[백준] 14889번 : 스타트와 링크 - 자바(JAVA)알고리즘/백준 2022. 8. 9. 00:01
https://www.acmicpc.net/problem/14889 14889번: 스타트와 링크 예제 2의 경우에 (1, 3, 6), (2, 4, 5)로 팀을 나누면 되고, 예제 3의 경우에는 (1, 2, 4, 5), (3, 6, 7, 8)로 팀을 나누면 된다. www.acmicpc.net 문제 해석 축구를 하기 위해 모인 사람은 N명이고 N은 짝수입니다. N/2명으로 두 팀을 나누려고 합니다. N=4일때 다음과 같이 시너지를 가집니다. 두 팀의 능력치의 차이를 최소로 하려고 합니다. 문제 풀이전 설계 S(i,j)는 1~100사이의 수 입니다. N은 4이상 20이하의 짝수입니다. 우선 두 그룹으로 나누는 작업을 수행합니다. (1,2) / (3,4) (1,3) / (2,4) (1,4) / (2,3) 이때 ..
-
JPA 동시성 문제 해결하기 (트랜잭션과 락)프로젝트/WebRTC 화상통화 프로젝트 2022. 8. 9. 00:01
동시성 문제란? 두개 이상의 세션이 공통된 자원에 대해서 읽고 쓰는 작업을 할 때 발생할 수 있는 문제입니다. 기본적으로 동시성 문제는 완전한 해결이 있는 것이 아닌 타협입니다. 성능을 포기하고 정확성을 높이느냐 vs 정확성을 타협하고 성능을 높이느냐 이러한 점을 명확하게 보여주는것이 바로 트랜잭션의 격리 단게입니다. Read Uncommited, Read Commited, Repeatable read, Serializable 일반적으로 주로 사용되는 DB는 주로 Rad Commited에 해당하는 격리수준을 가지고 있습니다. 하지만 JPA를 사용할 경우 영속성 컨텍스트에 캐시해놓기 때문에 Repeatable read 수준과 동일하게 동작하게 됩니다. JPA 에서는 영속성 컨텍스트에 캐시하기 때문에 "읽관..
-
nginx에 SSL 인증서 적용하기프로젝트/WebRTC 화상통화 프로젝트 2022. 8. 8. 17:21
지난 시간에 SSL 인증서를 발급받았습니다. letsencrypt 인증서 발급하고 OpenVidu에 적용하기 :: 매일매일 꾸준히 (tistory.com) letsencrypt 인증서 발급하고 OpenVidu에 적용하기 1. Ubunto 서버에서 다음 명령어를 통해 인증서를 발급받습니다. (인증서를 발급받기 위해서는 도메인이 필요합니다) sudo apt-get install letsencrypt # 만약 nginx를 사용중이면 중지 sudo systemctl stop ngin.. junuuu.tistory.com 이 인증서를 nginx에 적용하는 법을 알아보겠습니다. nginx란? https://junuuu.tistory.com/323 자세히 알고 싶으시면 위의 링크로 이동하시면 좋을 것 같습니다. 간단..
-
DockerFile과 commit 명령어로 웹서버 이미지 만들기MSA & 쿠버네티스(Kubernetes) - k8s 2022. 8. 8. 00:01
우리는 Docker Hub이라는 Docker에서 운영하는 이미지 저장소에서 도커 이미지를 받아서 run 명령어를 통해 컨테이너로 실행합니다. 만약 우리가 원하는 이미지를 생성하기 위해서는 어떻게 해야 할까요? 1. 컨테이너를 실행하여 commit 명령어로 이미지로 만들 수 있습니다. 2. 도커 파일을 생성하고 build 명령어로 이미지를 만들 수 있습니다. 이를 해석하자면 다음과 같습니다 우분투 20.04 os 환경에서부터 (FROM ~) 파이썬을 설치하고 (RUN~) : 도커 이미지가 생성되기 전에 수행할 쉘 명령어 /var/www/html 경로를 생성하고 (WORKDIR~) : 설정한 실행 파일이 실행될 디렉터리 index.html 파일을 해당 경로에 복사하고 (COPY~) EXPOSE : 호스트와 ..
-
[백준] 18870번 : 좌표 압축 - 자바(JAVA)알고리즘/백준 2022. 8. 7. 00:01
https://www.acmicpc.net/problem/18870 18870번: 좌표 압축 수직선 위에 N개의 좌표 X1, X2, ..., XN이 있다. 이 좌표에 좌표 압축을 적용하려고 한다. Xi를 좌표 압축한 결과 X'i의 값은 Xi > Xj를 만족하는 서로 다른 좌표의 개수와 같아야 한다. X1, X2, ..., XN에 좌 www.acmicpc.net 문제 해석 수직선 위에 N개의 좌표가 존재합니다. 이 좌표들을 압축하려고 합니다. X(i)를 좌표 압축한 결과 X`(i)의 값은 X(i) > X(j)를 만족하는 서로 다른 좌표의 개수와 같아야 합니다. 문제만 보고 이해가 잘 되지 않으면 예제를 보면 이해하기 쉽습니다. 5 2 4 -10 4 -9 -10은 정렬했을 때 0번째 수, -9는 첫번째 수,..