목록전체 글
Step-by-Step
https://leetcode.com/problems/edit-distance/description/ Edit Distance - LeetCode Can you solve this real interview question? Edit Distance - Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2. You have the following three operations permitted on a word: * Insert a character * D leetcode.com DP 사용해서 문제인데, 사실 너무 감이 오지 않아서 여러 검색을 통해 푸는 방법을..
AUTO_INCREMENT 속성을 사용하게 되면, 3 rows를 INSERT 후 모두 DELETE 해도 다음 값이 1이 아니라 4가 된다 처음 테이블을 만들때 부터 중간에 데이터가 삭제되어도 브레이크 없이 계속 올라가는 특징이 있다. AUTO_INCREMENT 값을 ALTER로 초기화해 줄 수 있다. ALTER TABLE 테이블명 AUTO_INCREMENT = 초기값 최근 PK 값을 가져와서 등록해주려고 SQL문을 만들었는데, ALTER TABLE post AUTO_INCREMENT = (SELECT IF(count(*) = 0, 0, max()) FROM post) BUT 안된다.. 이유가 뭘까 그냥 두 가지 sql 문을 따로 실행해주었다. MyBatis에서 DDL은 안될거같았지만, Update로 해두..
PK의 최근 값 가져오기 SELECT last_insert_id() FROM 테이블명 만약 테이블에 데이터가 하나도 없을 경우 다음과 같이 작성해주면 된다 SELECT IF(count(*) = 0, 디폴드 값, last_insert_id()) FROM 테이블명
https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/ Capacity To Ship Packages Within D Days - LeetCode Capacity To Ship Packages Within D Days - A conveyor belt has packages that must be shipped from one port to another within days days. The ith package on the conveyor belt has a weight of weights[i]. Each day, we load the ship with packages on the conveyor leetcode.com 풀긴 풀었는..
https://leetcode.com/problems/single-element-in-a-sorted-array/description/ Single Element in a Sorted Array - LeetCode Can you solve this real interview question? Single Element in a Sorted Array - You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Return the single element leetcode.com HashMap을 ..

사용자 비밀번호를 DB에 저장하려고 PasswordEncoder를 썼더니, Spring Security가 활성화돼서 자동으로 로그인 폼이 생기고,, 모든 URL 접근이 불가능해졌다 (403 Forbidden) [1] 우선 Config 파일 하나 만들기 @EnableWebSecurity @Configuration public class SecurityConfig { } [2] 로그인 폼 없애주기 @EnableWebSecurity @Configuration public class SecurityConfig { @Bean public SecurityFilterChain configure(HttpSecurity http) throws Exception { // Security 로그인 페이지 안 뜨도록 설정 ht..

https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/ResponseEntity.html ResponseEntity (Spring Framework 6.0.5 API) Create a ResponseEntity with a body, headers, and a raw status code. docs.spring.io ResponseEntity Header + Body 구성인 HttpEntity에서 HttpStatusCode를 추가하여 기능을 확장한 클래스 ResponseEntity 에서 T는 Body로 넣은 타입으로 생각하면 됨 ResponseDTO @Getter @Setter @AllArgsCon..
https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/ Binary Tree Zigzag Level Order Traversal - LeetCode Binary Tree Zigzag Level Order Traversal - Given the root of a binary tree, return the zigzag level order traversal of its nodes' values. (i.e., from left to right, then right to left for the next level and alternate between). Example 1: [https://assets leetcode.com DFS를 이용..

📜이전📜 [6] 구현 - 간단히 프로젝트 구조 설정 Spring에서 데이터베이스와 연결하는 대표적인 방법 2가지 1. JPA Java Persistence API - ORM(Object Relational Mapping) 표준 기술 Java의 객체와 관계형 DB를 맵핑하는 방식 객체 만들고 필드명 위에 @Column("데이터베이스 필드명") 해주면 데이터베이스에서 알아서 뽑아가고, 건네주는 방식 2. MyBatis 개발자가 직접 쿼리문 작성 SQL쿼리들을 한 구성파일에 구성하여 프로그램 코드와 SQL을 분리할 수 있는 장점 지님 JPA는 안드로이드 스튜디오 구현당시 retrofit2 사용할때 잠깐 편리함을 느꼈지만, MyBatis를 더 잘 다뤄보고 싶은 마음에 다시 MyBatis 선택 언제나 첫 시작은 ..
📜이전📜 [5] 기획 - SQL문 작성 프로젝트 구조 Controller - Service - Mapper.java - Mapper.xml - DB 지난번 프로젝트 참조함 - https://smile-development.tistory.com/59 Controller @RestController @RequestMapping("/user") public class UserController { @Autowired UserService userService; @PostMapping("/register") public ResponseEntity register(UserDTO userDTO) { System.out.println("register"); if(!userDTO.isNotNull()) return n..