분류 전체보기502 LeetCode 21(Merge Two Sorted Lists, java) 0. 문제 https://leetcode.com/problems/merge-two-sorted-lists/ Merge Two Sorted Lists - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 2개의 연결 리스트(list1, list2)가 주어진다. - 두 연결 리스트는 오름차순으로 정렬되어있다. - 두 연결 리스트를 오름차순으로 병합하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 우선 문제에서 주어진 연결 .. 2022. 4. 15. LeetCode 141(Linked List Cycle, java) 0. 문제 https://leetcode.com/problems/linked-list-cycle/ Linked List Cycle - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 한 개의 연결 리스트(head)가 주어진다. - 연결 리스트를 탐색하여 순환이 존재하는지 판단하는 것이 문제의 핵심이다. 2. 문제 해설 - 이 문제는 자칫 어려워 보일 수 있다. - 다만, 문제의 제약조건을 힌트로 사용한다면 굉장히 쉽게 풀리는 문제이다... 2022. 4. 15. LeetCode 242(Valid Anagram, java) 0. 문제 https://leetcode.com/problems/valid-anagram/ Valid Anagram - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 2개의 문자열(s, t)이 주어진다. - 문자열 t가 문자열 s의 아나그램인지 판별하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 우선 각 문자열의 길이를 구한다. - 만약 길이가 동일하지 않다면 아나그램이 될 수 없다. b) 두 번째 접근 - 각 문.. 2022. 4. 15. 18. 값 타입(1) - 개념 0. 개요 - 이번 포스팅에서는 JPA의 데이터 타입에 대해서 알아보자. 1. 값 타입 - JPA는 두 가지 데이터 타입을 사용한다. a) Entity 타입 - JPA의 최상위 타입이다. - @Entity로 정의된 클래스 객체를 의미한다. - Entity 타입은 값이 변경되어도 식별자(= id, PK)를 이용하여 추적이 가능하다. ex) 게시판의 1번 글(= 객체)의 내용이 수정 또는 삭제되어도 1번 아이디를 이용하여 객체의 상태를 추적할 수 있다. b) 값 타입 - int, String, Integer와 같이 자바의 Primitive 또는 Wrapper 클래스를 이용하여 생성된 객체 - 식별자가 없으므로 값의 변경 시 추적이 불가능하다. ex) int a = 100이라면, 이를 a = 200으로 변경해.. 2022. 4. 14. LeetCode 383(Ransom Note, java) 0. 문제 https://leetcode.com/problems/ransom-note/ Ransom Note - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 2개의 문자열(ransomNote, magazine)이 주어진다. - magazine을 구성하는 문자를 이용하여 ransomNote와 동일한 문자열을 만들 수 있는냐가 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 이 문제는 Magazine과 ransomNote을 구.. 2022. 4. 14. LeetCode 387(First Unique Character in a String, java) 0. 문제 https://leetcode.com/problems/first-unique-character-in-a-string/ First Unique Character in a String - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 문자열(s)이 주어진다. - 문자열을 구성하는 문자 중 가장 첫 번째로 중복이 없는 문자를 찾아 해당 문자의 index를 반환하는 것이 문제의 핵심이다. 2. 문제 해설 - 이 문제를 풀기 위해서.. 2022. 4. 14. LeetCode 74(Search a 2D Matrix, java) 0. 문제 https://leetcode.com/problems/search-a-2d-matrix/ Search a 2D Matrix - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 이중 배열(matrix)과 찾고자 하는 숫자(target)가 주어진다. - 이중 배열의 규칙과 구조를 파악하여 target을 찾는 가장 효율정인 탐색 알고리즘을 작성하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 우선 문제에서 주어지.. 2022. 4. 14. LeetCode 36(Valid Sudoku, java) 0. 문제 https://leetcode.com/problems/valid-sudoku/ Valid Sudoku - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 이중 배열(board)이 주어진다. - 이중 배열(board)은 수도쿠 문제를 만들기 위해서 생성된 것이다. - 이 문제의 핵심은 주어진 이중 배열(board)이 수도쿠로써 이상이 없는지 파악하는 것이다. 2. 문제 해설 a) 전제 조건 - 우선 문제에서 주어진 조건을 보자.. 2022. 4. 13. 17. 고아 객체(Orphan) 0. 개요 - 이번 포스팅에서는 고아 객체란 무엇인지 알아보자. 1. 고아 객체(Orphan) a) 개념 - 고아 객체는 부모 객체와 연관 관계가 끊어진 자식 객체를 의미한다. b) orphanRemoval 옵션 - JPA는 자식 객체가 고아 객체의 상태가 되면 해당 객체를 자동으로 삭제하는 기능을 가진다. - 이는 다음 사진처럼 옵션으로 설정이 가능하다. - 위의 코드는 childList에서 삭제된 객체를 연관 관계가 끊긴 것으로 판단하여 객체 자체를 삭제한다. - 옵션을 설정한 후, 다음과 같은 코드를 실행해보자. - 위의 코드를 실행하면 다음과 같아 DELETE 쿼리가 자동으로 발생하는 것을 확인할 수 있다. - 다음 사진과 같이, 연관 관계가 끊긴 자식 객체가 DB에서 삭제된 것을 확인할 수 있다.. 2022. 4. 13. 이전 1 ··· 8 9 10 11 12 13 14 ··· 56 다음