목록공부 (58)
기록을 합시다.
문제 요약 마라톤에 참여 하였지만 마라톤을 완주하지 못 한 사람을 구해야 한다. 중복된 이름이 있어서 그 점을 유의해야 한다. 문제에 나와있듯, 완주하지 못 한 사람은 딱 한 명이다. 내가 생각한 로직(python) collections 라이브러리의 Counter 클래스를 사용하여, 완주한 사람과 완주하지 못 한 사람을 이름 별로 세어준 딕셔너리 생성 딕셔너리들끼리 -연산을 한다. (python에서는 딕셔너리끼리 +, - 연산 가능) 값이 0이 아닌 이름이 곧 정답 파이썬으로 제출한 정답 from collections import Counter def solution(participant, completion): participant_dic = Counter(participant) completion_d..
문제 요약 모든 명함을 담을 수 있는 명함 케이스의 크기를 구하라 명함의 크기는 가로, 세로로 회전해서 넣을 수 있으므로 이 점 고려해야함 내가 생각한 로직 모든 명함의 가로, 세로를 크기 순으로 정렬한다. (ex. [30,70] => [70,30]) 크기순으로 정렬한 명함들 안에서 첫 번째 요소의 max값과 두 번째 요소의 max값을 구한다. 파이썬으로 제출한 정답 def solution(sizes): sorted_sizes = [] max_width = -1 max_height = -1 for size in sizes : n, m = size if n >= m: sorted_sizes.append(size) else: sorted_sizes.append([m, n]) for size in sorted..
문제 요약 commands변수에 담긴 명령들을 이용해서 배열을 부분 정렬하고, 부분 정렬한 곳에서 특정 인덱스의 값들을 반환하라. 파이썬으로 제출한 정답 def solution(array, commands): answer = [] for command in commands: a, b, idx = command new_list = sorted(array[a-1:b]) answer.append(new_list[idx-1]) return answer자바로 제출한 정답 import java.util.*; class Solution { public List solution(int[] array, int[][] commands) { List answer = new ArrayList(); for(int[] comma..
문제 요약 배열에서 나타나는 연속적인 숫자를 하나만 남기고 전부 제거하라. 파이썬으로 제출한 정답 def solution(arr): tmp = -1 answer = [] for i in arr: if tmp == i: continue else: tmp = i answer.append(i) return answer 자바로 제출한 정답 import java.util.*; public class Solution { public List solution(int []arr) { int tmp = -1; List answer = new ArrayList(); for(int num : arr){ if(tmp == num){ continue; }else{ //tmp와 num이 다를 때 tmp = num; answer...
문제 요약 폰켓몬은 제시된 폰켓몬 n개 중에서 2/n마리 가질 수 있다. 2/n 마리 중에는 중복은 있을 수 없다. 중복을 제외하면 최대 몇 마리까지 가질 수 있는지가 정답이다. 파이썬으로 제출한 정답 def solution(nums): types = len(set(nums)) n = len(nums) if n//2 > types: return types if n//2 types: return types if n//2
팀플을 현재 진행 하고 있는데, 도커 파일 하나 만들어서 다 같이 쓰면 좋을 것 같다는 생각을 했다. 그래서 한 번 도커 이미지 만들어보기 도전을 해보았다. 도커 프로젝트 폴더 생성하기 mkdir project-dockerfile 도커 프로젝트 내에서 도커 파일 생성하기 참고로 도커파일은 확장자가 없고, 그냥 파일명 자체가 Dockerfile이니 주의하자. FROM gvenzl/oracle-xe ENV ORACLE_PASSWORD=1234 RUN mkdir files VOLUME [ "/oradata:/opt/oracle/oradata/gvenzl/oracle-xe" ] COPY 001_projectDB.sql /container-entrypoint-initdb.d EXPOSE 1521 참고한 이미지는 ..
프로젝트 경로 +---dockerfile_apache2 | Dockerfile | httpd-vhosts.conf | httpd.conf | +---dockerfile_mariadb | db_board.sql | db_user.sql | Dockerfile | +---dockerfile_tomcat9 | Board.war | Dockerfile | server.xml | +---etc | Board.war | index.html | serverVersionView.jsp | \---miniboard_compose docker-compose.yml Apache2 Dockerfile 작성 FROM httpd #귀찮으니 안에서 설정안 하기 위해서 conf 파일들을 아예 옮겨준다. ADD httpd.conf /..
HTTP HTTP 개념 HTTP(Hypertext Transfer Protocol)이란 인터넷에서 데이터를 주고받기 위한 통신 규약으로, 웹에서 클라이언트와 서버 간에 데이터를 주고 받을 때 사용된다. HTTP 목적 클라이언트와 서버 간에 웹 리소스(HTML 문서, 이미지, 동영상 등)을 주고 받는 것이다. 클라이언트는 웹 브라우저를 통해 서버에게 HTTP 요청을 보내고, 서버는 클라이언트에게 HTTP 응답을 전송해준다. HTTP 특징 비연결성(Connectionless): 클라이언트가 요청을 보내고 서버가 응답을 보내면 연결이 끊긴다. 이런 특징으로 서버의 자원을 효율적으로 사용할 수 있다. 무상태성(Stateless): HTTP 요청과 응답은 서로 독립적으로 이루어지기 때문에, 서버는 클라이언트의 이..
설정 spring boot 버전 : 3.0.6 dependency 설정 dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' annotationProcessor 'org.projectlombok:lombok' compileOnly 'org.projectlombok:lombok' developmentOnly 'org.springframework.boot:spring-boot-devtools' //spring security implementation 'org.springframework.boot:spring-boot-starter-security' //jwt implementation 'io.jsonwebt..
JPA(Java Persistence API) JPA - Introduction JPA Introduction - Any enterprise application performs database operations by storing and retrieving vast amounts of data. Despite all the available technologies for storage management, application developers normally struggle to perform database operation www.tutorialspoint.com Java Persistence API는 방대한 양의 데이터를 데이터베이스에 지속적으로 저장하기 위한 클래스와 메서드의 모음이다. J..