소스 코드는 여기 있습니다. 문제는 여기 있습니다. Problem You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition: struct Node { int val; Node *left; Node *right; Node *next; } Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL. Initially,..
모든 소스 코드는 여기 있습니다. 이전 포스팅에 이어서 Querydsl의 기본 문법을 소개합니다. 기본 Join 첫 번 째 파라미터에 join할 대상, 두 번 째 파라미터에 별칭으로 사용할 Q Type을 지정합니다. package io.lcalmsky.querydsl.domain; import com.querydsl.jpa.impl.JPAQueryFactory; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBoot..
모든 소스 코드는 여기 있습니다. 이전 포스팅에 이어서 Querydsl의 기본 문법을 소개합니다. 정렬 JPAQueryFactory에서 orderBy 메서드를 호출해 정렬 기능을 사용합니다. orderBy의 파라미터로 정렬할 항목들을 전달하는데 아래 테스트 코드처럼 작성하면 됩니다. package io.lcalmsky.querydsl.domain; import com.querydsl.jpa.impl.JPAQueryFactory; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.spring..
모든 소스 코드는 여기 있습니다. Querydsl의 기본 문법을 소개합니다. Q Type 이전 포스팅에서 사용한 Entity들을 compileQuerydsl을 이용해 모두 Q Type으로 변환하였습니다. (자세한 내용은 이전 포스팅 참고) Q Type 객체를 사용하는 방법은 이전 포스팅에서도 소개했지만 두 가지가 있습니다. QPlayer player = new QPlayer("p"); // (1) QPlayer player = Qplayer.player; // (2) (1) alias를 별도로 지정하고 new를 이용해 객체를 생성합니다. (2) QPlayer클래스에 static으로 선언된 객체를 가져와 사용합니다. alias의 기본 값은 Entity 이름 입니다. (Player인 경우 player) 굳이..
소스 코드는 여기 있습니다. 문제는 여기 있습니다. Problem Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue. We will use the integers 0, 1, and 2 to represent the color red, white, and blue, respectively. You must solve this problem without using the library's sort function. Example ..
스프링 부트 2.6 이상은 아래 글을 참고해주세요. 2022.08.23 - [Querydsl] - 스프링부트 2.6 이상 버전에서 Querydsl 설정 방법 모든 소스 코드는 여기 있습니다. Querydsl을 사용하기 위해 프로젝트 설정부터 차근차근 달려봅시다! 먼저 자바 버전은 11, 스프링 버전은 2.5.2를 선택하였고 gradle 프로젝트로 생성하여 아래 네 가지 dependency를 설정하였습니다. spring-boot-starter-web spring-boot-starter-data-jpa lombok h2 build.gradle 위와 같이 설정하셨다면 build.gradle 파일이 아래 처럼 작성되었을텐데요, plugins { id 'org.springframework.boot' version..
모든 소스 코드는 여기서 확인 가능합니다. 문제 링크는 여기 있습니다. Problem Given the head of a linked list, remove the nth node from the end of the list and return its head. Example 1: Input: head = [1,2,3,4,5], n = 2 Output: [1,2,3,5] Example 2: Input: head = [1], n = 1 Output: [] Example 3: Input: head = [1,2], n = 1 Output: [1] Constraints: The number of nodes in the list is sz. 1 test(ListNode.of(1, 2, 3), 1, ListNode..
모든 소스 코드는 여기 있습니다. LeetCode에서 알고리즘 문제를 풀다보면 ListNode를 이용해 테스트 해야할 일이 많이 있습니다. 테스트 코드나 main 메서드 내에서 객체를 생성하고 ListNode를 파라미터로 넘겨주다보면 매우 불편한 경우가 많이 있습니다. 먼저 LeetCode에서 주어지는 ListNode를 살펴보면 public class ListNode { int val; ListNode next; ListNode() { } ListNode(int val) { this.val = val; } ListNode(int val, ListNode next) { this.val = val; this.next = next; } } 이렇게 되어있습니다. 단순하게 생성자를 통해 value를 주입하고 다음..
) 모든 소스 코드는 여기에서 확인할 수 있습니다. 바로 이전 포스팅에서 JPA가 save()를 호출할 때 새로운 Entity인지 기존 Entity인지 판단해 persist() 또는 merge()를 호출한다는 내용을 다룬 바 있습니다. 그렇다면 JPA는 과연 어떻게 새로운 Entity인지 판단하는 것 일까요? 설명을 위해 간단한 소스 코드를 작성해보겠습니다. package io.lcalmsky.springdatajpa.domain.entity; import lombok.Getter; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; @Entity @Getter public..
모든 소스 코드는 여기 서 확인 가능합니다. 문제 링크는 여기 있습니다. Problem A peak element is an element that is strictly greater than its neighbors. Given an integer array nums, find a peak element, and return its index. If the array contains multiple peaks, return the index to any of the peaks. You may imagine that nums[-1] = nums[n] = -∞. You must write an algorithm that runs in O(log n) time. Example 1: Input: nums = ..
- Total
- Today
- Yesterday
- QueryDSL
- 스프링 부트 튜토리얼
- Spring Boot JPA
- spring boot app
- 스프링 데이터 jpa
- Spring Boot
- leetcode
- JPA
- 스프링 부트 회원 가입
- Jackson
- 클린 아키텍처
- spring boot jwt
- 함께 자라기 후기
- @ManyToOne
- r
- Spring Data JPA
- Java
- Spring Boot Tutorial
- 알고리즘
- gRPC
- 스프링 부트
- 스프링부트
- 함께 자라기
- proto3
- Linux
- spring boot application
- intellij
- 스프링 부트 애플리케이션
- 헥사고날 아키텍처
- JSON
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |