전체 글
-
[백준] 3078번 : 좋은 친구 - 자바(JAVA)알고리즘/백준 2022. 7. 30. 00:01
https://www.acmicpc.net/problem/3078 3078번: 좋은 친구 첫째 줄에 N과 K가 주어진다. (3 ≤ N ≤ 300,000, 1 ≤ K ≤ N) 다음 N개 줄에는 상근이네 반 학생의 이름이 성적순으로 주어진다. 이름은 알파벳 대문자로 이루어져 있고, 2글자 ~ 20글자이다. www.acmicpc.net 문제 해석 모든 학생은 자신과 반 등수의 차이가 K를 넘으면 친구가 아니다. 이때 좋은 친구는 이름의 길이가 같아야 합니다. N명의 학생들의 이름이 성적순으로 주어졌을 때 좋은 친구가 몇 쌍이나 있는지 구하세요 좋은 친구 = 등수의 차이가 K보다 작거나 같으면서 이름의 길이가 같음 문제 풀이 전 설계 우선 N은 최대 30만입니다. 좋은 친구의 문서 쌍을 구해야 합니다. 투 포인..
-
JPA Entity 연관관계 구현하기(양방향 연관관계 List Empty 문제 해결)프로젝트/WebRTC 화상통화 프로젝트 2022. 7. 29. 00:04
개요 JPA의 다양한 연관관계를 구현해보려고 합니다. 1: N, 1:1, N:M을 다뤄보겠습니다. 어느 정도 JPA에 대한 지식이 있다는 전제하에 진행됩니다. N : M 연관관계 구현하기(회원 - 그룹) 현재 로그인기능만 구현한 상황이기 때문에 Member Entity만 존재합니다. 회원은 여러개의 그룹에 가입할 수 있습니다. (1 : N) 그룹은 여러명의 회원을 가질 수 있습니다. (1 : N) 두 엔티티가 모두 1:N 관계를 가지기 때문에 N:M 연관관계입니다. @ManyToMany라는 어노테이션이 존재하지만 중간 테이블을 묵시적으로 생성해주기 때문에 필요한 추가 칼럼을 사용할 수 없는 문제가 발생합니다. Member_Group이라는 중간 테이블을 두어 N:M을 1:N, N:1으로 풀어내고자 합니다...
-
[백준] 16500번 : 문자열 판별 - 자바(Java)알고리즘/백준 2022. 7. 29. 00:01
https://www.acmicpc.net/problem/16500 16500번: 문자열 판별 첫째 줄에 길이가 100이하인 문자열 S가 주어진다. 둘째 줄에는 A에 포함된 문자열의 개수 N(1 ≤ N ≤ 100)이 주어진다. 셋째 줄부터 N개의 줄에는 A에 포함된 단어가 한 줄에 하나씩 주어진다. A에 www.acmicpc.net 문제 해석 알파벳 소문자로 이루어진 문자열 S가 있습니다 알파벳 소문자로 이루어진 단어 A가 있습니다. 이때 A에 포함된 단어목록을 한 개 이상 공백없이 붙여서 만들 수 있는지 없는지 구하는 프로그램을 작성하세요. 문자열 S의 길이는 100이하입니다. A의 개수도 100개이하입니다. 문자열 S : softwarecontest 단어A : software, contest 단어A를..
-
세션 하이재킹과 TCP Sequence NumberCS/네트워크 2022. 7. 28. 00:01
세션 하이재킹이란? 세션은 클라이언트와 서버 두 대의 컴퓨터 간의 활성화된 상태를 말합니다. 이때 세션 하이재킹은 로그인된 상태를 가로채는 것을 말합니다. TCP 세션 하이재킹은 TCP의 고유한 취약점을 이용하여 정상적인 접속을 빼앗는 방식입니다. TCP는 클라이언트와 서버 간 통신을 할 때 패킷의 연속성을 보장하기 위해 각각 시퀀스 넘버를 사용합니다. 이 시퀀스 넘버가 잘못되면 이를 바로잡기 위한 작업을 하는데 TCP 세션 하이재킹은 서버와 클라이언트에 각각 잘못된 시퀀스 넘버를 위조하여 연결된 세션에 혼란을 주고 자신이 끼어들어가는 방식입니다. TCP 패킷 TCP 프로토콜은 신뢰형 프로토콜로 다음과 같은 기능을 제공합니다. 1. 데이터 양을 조절하는 흐름 제어 2. 데이터 유실에 대처하는 오류 제어 ..
-
[백준] 20303번 : 할로윈의 양아치 - 자바(JAVA)알고리즘/백준 2022. 7. 27. 00:01
https://www.acmicpc.net/problem/20303 20303번: 할로윈의 양아치 첫째 줄에 정수 $N$, $M$, $K$가 주어진다. $N$은 거리에 있는 아이들의 수, $M$은 아이들의 친구 관계 수, $K$는 울음소리가 공명하기 위한 최소 아이의 수이다. ($1 \leq N \leq 30\ 000$, $0 \leq M \leq 100\ 000$, www.acmicpc.net 문제 해석 스브러스는 사탕을 뺏으려고 한다. 이때 스브러스는 사탕을 뺏을 때 한 아이의 사탕을 뺏으면 그 아이 친구들의 사탕도 모조리 뺏어버립니다. 이때 K명 이상의 아이들의 뺏지 않으면서 최대로 뺏을 수 있는 사탕의 양을 구하세요 문제 풀이전 설계 거리에 있는 아이들의 수 N = 30,000 아이들의 친구 관계..
-
Controller 단위테스트 하기프로젝트/WebRTC 화상통화 프로젝트 2022. 7. 26. 16:36
개요 - MemberController를 단위 테스트하려고 합니다. - MemberController는 MemberService를 의존하고 있습니다. - @WebMvcTest를 사용하여 테스트합니다. GET +QueryParam 조회 컨트롤러 메서드 @GetMapping("/info/{nickname}") public ResponseEntity memberInfo(@PathVariable(value = "nickname") String nickname) { Member member = memberService.getUserInfo(nickname); return new ResponseEntity(makeBasicResponse(SUCCESS, member.toMemberResponse()), HttpSt..
-
[백준] 1615번 : 교차개수세기 - 자바(Java) , C++알고리즘/백준 2022. 7. 26. 00:01
https://www.acmicpc.net/problem/1615 1615번: 교차개수세기 첫 줄에 N과 간선의 개수 M이 주어진다. 그 다음 줄부터 M+1번째 줄까지 두 개의 수(i, j)가 주어지는데 이는 왼쪽 그룹의 i번 정점과 오른쪽 그룹의 j번 정점을 연결하는 간선이 있다는 의미이다. www.acmicpc.net 문제 해석 각각 N개의 쌍으로 이루어진 2N개의 정점과 M개의 간선으로 구성된 이분 그래프가 주어집니다. M은 최대 2000*1999/2 = 1999000 -> 약 2백만개 이때 선분끼리 서로 교차하는 총개수를 구하세요. 선분의 교차 조건 (A1, B1) (A2, B2)라고 했을 때 A1 B2 또는 A1 > A2, B1 < B2를 만족한다면 두 간선은 교차합니다. 결..
-
Java Lazy Evaluation이란?Java 2022. 7. 24. 00:01
Lazy Evaluation이란? 실제로 필요한 경우에만 연산을 시작하는 것을 의미합니다. 반대로 eager evaluation은 할당되자마자 연산을 시작합니다. Java는 eager evaluation을 기본으로 하고 일부 Lazy Evaluation이 존재했습니다. Java8이 나오면서 Java에서 Lazy Evauation을 좀 더 유연하게 사용할 수 있습니다. Eagar Evaluation 예시 public class LazyEvaluation { public static void main(String[] args) throws InterruptedException { double start = System.currentTimeMillis(); printIfValid(0,expensiveMetho..