전체 글502 LeetCode 700(Search in a Binary Search Tree, java) 0. 문제 https://leetcode.com/problems/search-in-a-binary-search-tree/ Search in a Binary Search Tree - 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. 문제 설명 - 문제에서 이진 탐색 트리(= root)와 정수(= val)가 주어진다. - 이진탐색트리를 탐색하는 과정에서 어떤 노드의 value가 주어진 정수(= val)와 동일한 경우를 찾는다. - 해당 노드의 모든 자식 노드를 반.. 2022. 4. 21. LeetCode 112(Path Sum, java) 0. 문제 https://leetcode.com/problems/path-sum/ Path Sum - 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. 문제 설명 - 문제에서 이진트리(root)와 정수(targetSum)가 주어진다. - 루트 노드를 시작으로 단말 노드까지의 value를 합하여 targetSum을 만들 수 있는지 확인하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 우선 true를 반환하는 경우를 생각해보자. - 가장 먼저 생.. 2022. 4. 21. 22. JPQL - JPQL에 대하여 0. 개요 - 이전 포스팅까지 기본적인 JPA의 개념과 기능에 대해서 알아보았다. - JPA는 객체 간의 관계를 RDB 형태로 변환 및 매핑을 돕는 기술이다. - 그러므로 JPA는 객체 중심적으로 작성된 코드를 RDB에 적용할 수 있도록 해당 코드를 쿼리문으로 변환하는 역할을 한다. - 전반적인 과정을 보면 근본적인 개념은 달라지지 않았다. - 개발자가 쿼리문을 직접 작성하지 않고 이를 객체 지향적 코드로 작성할 뿐, 내부적으로는 쿼리문이 발생하기 때문이다. - 즉, 객체 중심적 코드를 이용하여 자유자재로 쿼리를 구현할 수 있어야 한다. - 지금까지 객체 간의 관계를 RDB의 형태로 전환하는 방법을 배웠다. - 그러나 실무에서는 훨씬 복잡한 관계를 구현하는 경우가 대부분이다. - 복잡한 관계를 JPA에서.. 2022. 4. 20. LeetCode 226(Invert Binary Tree, java) 0. 문제 https://leetcode.com/problems/invert-binary-tree/ Invert Binary Tree - 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. 문제 설명 - 문제에서 이진트리(root)가 주어진다. - 문제에서 주어진 이진트리(root)를 대칭한 모양으로 바꾸는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 이 문제는 생각보다 간단하다. 루트 노드를 제외한 모든 자식 노드의 위치를 서로 변경하면 된다.. 2022. 4. 20. LeetCode 101(Symmetric Tree, java) 0. 문제 https://leetcode.com/problems/symmetric-tree/ Symmetric Tree - 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. 문제 설명 - 문제에서 이진트리(root)가 주어진다. - 해당 이진트리의 모든 노드가 가진 값을 탐색 및 비교하여 대칭하는지를 판단하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 최초에 루트 노드가 가진 좌/우측 자식은 1개씩이므로, 이 둘의 value를 비교하면 대칭.. 2022. 4. 20. LeetCode 104(Maximum Depth of Binary Tree, java) 0. 문제 https://leetcode.com/problems/maximum-depth-of-binary-tree/ Maximum Depth of Binary Tree - 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. 문제 설명 - 문제에서 이진트리(root)가 주어진다. - 이 이진트리를 탐색하여 이진트리의 깊이를 반환하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 이 문제는 이전에 풀어본 102번 문제에서 사용한 깊이 단위 탐색을 .. 2022. 4. 20. 21. 값 타입(4) - 값 타입과 컬렉션 0. 개요 - 이번 포스팅에서는 값 타입을 사용한 collection에 대해서 알아보려 한다. - 결론부터 말하면 값 타입 collection은 사용하지 않는다. - 값 타입 collection이 무엇인지, 왜 사용하지 않는지에 대해서 알아보자. 1. 값 타입과 collection 사용법 - 이전 포스팅에서 일대다(1:N) 관계를 표현할 때, Entity를 collection에 담아서 사용해본 적이 있다. - 값 타입 또한 collection에 담아서 사용할 수 있는데, 그 방법에 대해서 알아보자. a) 예시 케이스 - 예를 들어, 위의 사진과 같은 축구 선수 Entity를 구성하려고 한다. → Player는 Entity이다. → Game은 출전한 경기를 기록하는 값 타입이다. → preferPos는 선.. 2022. 4. 19. LeetCode 102(Binary Tree Level Order Traversal, java) 0. 문제 https://leetcode.com/problems/binary-tree-level-order-traversal/ Binary Tree Level Order Traversal - 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. 문제 설명 - 문제에서 이진트리(root)가 주어진다. - 이진트리(root)를 깊이 단위로 탐색하며, 동일한 깊이에 있는 모든 노드를 하나의 배열로 묶는다. - 이렇게 깊이 단위로 묶인 각 배열을 하나의 배열 안에 넣어 .. 2022. 4. 19. LeetCode 145(Binary Tree Postorder Traversal, java) 0. 문제 https://leetcode.com/problems/binary-tree-postorder-traversal/ Binary Tree Postorder Traversal - 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. 문제 설명 - 문제에서 이진트리(root)가 주어진다. - 해당 이진트리를 후위 순회 방식으로 탐색하여, 탐색한 순서대로 노드의 값을 배열에 담아 반환하는 것이 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 후위 순회는 좌측 .. 2022. 4. 19. LeetCode 94(Binary Tree In-order Traversal, java) 0. 문제 https://leetcode.com/problems/binary-tree-inorder-traversal/ Binary Tree Inorder Traversal - 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. 문제 설명 - 문제에서 이진트리(root)가 주어진다. - 주어진 이진트리를 중위 순회 순서로 탐색하여, 방문한 노드의 값을 배열에 담아 반환하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 우선 중위 순회는 좌측 자식.. 2022. 4. 19. 20. 값 타입(3) - 객체 비교와 equals() 재정의 0. 개요 - 이번 포스팅에서는 값 타입 객체를 이용한 비교에 대해서 알아보자. 1. 값 비교 a) 일반적인 값 비교 - 일반적으로 Java에서는 값을 비교할 때 비교 연산자(==)와 equals를 사용한다. → 동일성(identity) 비교: 비교 연산자(==)를 사용하여 참조 값을 비교한다. 즉, 메모리 주소 값을 비교한다. → 동등성(equivalance) 비교: equals() 메서드를 사용하여 객체의 내용을 비교한다. 즉, 객체의 값(= value)을 비교한다. - 다음 예시를 살펴보자. public class JpaMain { public static void main(String[] args) { Integer a = new Integer(10); Integer b = new Integer(.. 2022. 4. 18. LeetCode 144(Binary Tree Preorder Traversal, java) 0. 문제 https://leetcode.com/problems/binary-tree-preorder-traversal/ Binary Tree Preorder Traversal - 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. 문제 설명 - 문제에서 이진트리(root)가 주어진다. - 이 문제는 이진트리를 전위 순회(Preorder)로 탐색하여 방문한 노드를 리스트로 반환하는 것이 핵심이다. - 이진 트리를 탐색하는 방법에는 3가지가 있다. → 전위 순회(.. 2022. 4. 18. 이전 1 ··· 4 5 6 7 8 9 10 ··· 42 다음