전체 글
-
[백준] 18808번 : 스티커 붙이기 - 자바(JAVA)알고리즘/백준 2022. 5. 6. 00:01
https://www.acmicpc.net/problem/18808 18808번: 스티커 붙이기 혜윤이는 최근에 다양한 대회를 참여하면서 노트북에 붙일 수 있는 스티커들을 많이 받았다. 스티커는 아래와 같이 사각 모눈종이 위에 인쇄되어 있으며, 스티커의 각 칸은 상하좌우로 모두 연 www.acmicpc.net 문제 이해 여러 개의 스티커가 존재합니다. 스티커는 각 칸이 상하좌우로 모두 연결되어 있습니다. 주황색 칸은 스티커가 붙은 칸, 하얀색 칸은 스티커가 붙지 않은 칸을 나타냅니다. 모눈종이의 크기는 스티커의 크기와 꼭 맞아 스티커가 포함되지 않는 행이나 열은 존재하지 않습니다. 직사각형 모양의 노트북에 스티커들을 차례대로 붙이려고 합니다. 1. 스티커는 회전시키지 않고 모눈종이에서 떼어낸다. 2. 다..
-
Controller에 인자값은 어떤값이 올 수 있을까?프로젝트/게시판 프로젝트 2022. 5. 6. 00:01
Controller가 매우 다양한 인자 값을 받아올 수 있기 때문에 어떤 값들을 받아 올 수 있는지 어떻게 받아오는 게 적절할지 조사해보고자 합니다. Spring Controller에서 Parameter를 받는 방식 HttpServletRequest를 통해 받는 방법 @RequestMapping("/test") public String test(HttpServletRequest req) { String userId = req.getParameter("userId"); String password = req.getParameter("password"); return "test"; } getParameter()는 String값을 반환합니다. 이때 parameter로 보낸 변수명과 getParameter("변..
-
RestController에서 클라이언트에게 어떤 값을 반환해야 할까?프로젝트/게시판 프로젝트 2022. 5. 5. 03:41
Spring Boot를 활용하여 REST API를 만들던 도중 클라이언트에게 값을 반환하는 방법은 어떤 것들이 존재하며 어떤 값을 반환해야 할지 정리하면 좋을 것 같아 해보려고 합니다. 우선 반환하는 방법들에는 어떤것들이 존재할까요? 1. String반환(단순 문자열) @RestController public class testController{ @RequestMapping("/test") public String test1(){ return "test"; } } 문자열 데이터는 기본적으로 text/html 타입을 처리됩니다. "test"라는 메시지가 HTTP ResponseBody에 직접 쓰이게 됩니다. 2. 객체 반환 @RestController public class testController{ ..
-
[백준] 19238번 : 스타트 택시 - 자바(JAVA)알고리즘/백준 2022. 5. 5. 00:01
https://www.acmicpc.net/problem/19238 19238번: 스타트 택시 첫 줄에 N, M, 그리고 초기 연료의 양이 주어진다. (2 ≤ N ≤ 20, 1 ≤ M ≤ N2, 1 ≤ 초기 연료 ≤ 500,000) 연료는 무한히 많이 담을 수 있기 때문에, 초기 연료의 양을 넘어서 충전될 수도 있다. 다 www.acmicpc.net 문제 해석 스타트 택시는 손님을 도착지로 데려다줄 때마다 연료가 충전된다. (연료는 승객을 태워 이동하면서 소모한 연료 양의 2배가 충전된다.) 연료가 바닥나면 그날의 업무는 끝난다. (실패 시 -1 출력) 택시 기사 최백준은 M명의 승객을 태우는 것이 목표이다. 활동할 영역은 N*N 크기의 격자이다. 각 칸은 비어있거나 벽이 놓여있다. 상하좌우 인접 칸으로..
-
Entity와 DTO를 분리하자!프로젝트/게시판 프로젝트 2022. 5. 4. 00:55
클라이언트에서 정보를 받아오면 Member Entity를 그대로 사용하려고 하였습니다. 하지만 그렇게 되면 Controller 및 Service에 사용하게 될 로직들이 Entity의 속성 값과 의존관계를 맺게 됩니다. 하지만 Entity는 매우 중요한 객체로 사용범위도 크고 모든 데이터를 갖고 있는 객체이므로 Entity와 서비스가 의존관계를 갖게 하는 것은 유지보수 측면에서나 관리측면에서 매우 부적합합니다. DTO 객체는 View Layer와 데이터를 주고받을 때 사용합니다. Entity 객체는 DB Layer와 데이터를 주고받을 때 사용합니다. 실제로 Controller에서 결괏값으로 여러 테이블을 join 해서 줘야 할 경우가 빈번하기 때문에 Entity 클래스만으로 표현하기 어려운 경우도 많습니다..
-
[백준] 2309번 : 일곱난쟁이 - 자바(JAVA)알고리즘/백준 2022. 5. 4. 00:01
https://www.acmicpc.net/problem/2309 2309번: 일곱 난쟁이 아홉 개의 줄에 걸쳐 난쟁이들의 키가 주어진다. 주어지는 키는 100을 넘지 않는 자연수이며, 아홉 난쟁이의 키는 모두 다르며, 가능한 정답이 여러 가지인 경우에는 아무거나 출력한다. www.acmicpc.net 문제 해석 조합 문제로 9C7 == 100을 찾는 문제 정답이 여러 개 존재할 수 있어서 한 개만 출력해야 하는 것과 정렬해주는 것만 주의하면 됩니다. 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class Main_2309..
-
[백준] 10974번 : 모든순열 - 자바(JAVA)알고리즘/백준 2022. 5. 4. 00:01
https://www.acmicpc.net/problem/10974 10974번: 모든 순열 N이 주어졌을 때, 1부터 N까지의 수로 이루어진 순열을 사전순으로 출력하는 프로그램을 작성하시오. www.acmicpc.net 문제 해석 단순하게 순열을 만드는 문제입니다. 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main_10974_모든순열 { static int[] answers; static boolean[] visited; static int N; public static void main(String[] args) throws NumberFormatE..
-
[백준] 1194번 : 달이 차오른다, 가자. - 자바(Java)알고리즘/백준 2022. 5. 3. 00:01
https://www.acmicpc.net/problem/1194 1194번: 달이 차오른다, 가자. 첫째 줄에 미로의 세로 크기 N과 가로 크기 M이 주어진다. (1 ≤ N, M ≤ 50) 둘째 줄부터 N개의 줄에 미로의 모양이 주어진다. 같은 타입의 열쇠가 여러 개 있을 수 있고, 문도 마찬가지이다. 그리고, www.acmicpc.net 문제 해석 직사각형의 미로는 다음과 같이 구성되어 있다. 빈칸: 언제나 이동할 수 있다. ('.') 벽: 절대 이동할 수 없다. ('#') 열쇠: 언제나 이동할 수 있다. 이곳에 처음 들어가면 열쇠를 집는다. ('a', 'b', 'c', 'd', 'e', 'f') 문: 대응하는 열쇠가 있을 때만 이동할 수 있다. ('A', 'B', 'C', 'D', 'E', 'F')..