전체 글502 LeetCode 283(Move Zeroes, java) 0. 문제 https://leetcode.com/problems/move-zeroes/ Move Zeroes - 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. 문제 설명 - 문제에서 정수형 배열(nums)이 주어진다. - 배열의 원소 중 0인 원소를 배열의 가장 마지막 위치부터 채운다. - 0을 제외한 나머지 원소들은 오름차순으로 정렬하여 배열의 첫 번째 위치부터 채운다. 2. 문제 해설 a) 첫 번째 접근 - 이 문제는 버블 정렬을 사용하면 쉽게 풀 수 .. 2022. 4. 24. LeetCode 189(Rotate Array, java) 0. 문제 https://leetcode.com/problems/rotate-array/ Rotate Array - 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. 문제 설명 - 문제에서 정수형 배열(nums)과 반복 횟수(k)가 주어진다. - 주어진 배열의 원소를 k만큼 우측으로 한 칸씩 이동시키는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 이 문제가 까다로운 이유는 문제에서 주어진 메서드가 void 타입이라는 것이다. - 즉, 반환형이.. 2022. 4. 24. LeetCode 977(Squares of a Sorted Array, java) 0. 문제 https://leetcode.com/problems/squares-of-a-sorted-array/ Squares of a Sorted Array - 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. 문제 설명 - 문제에서 정수형 배열(nums)이 주어진다. - 정수형 배열의 모든 요소의 제곱을 배열에 저장하고 이를 오름차순으로 반환하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 가장 간단한 해결 방법은 for문을 사용하여 원소.. 2022. 4. 24. LeetCode 35(Search Insert Position, java) 0. 문제 https://leetcode.com/problems/search-insert-position/ Search Insert Position - 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. 문제 설명 - 문제에서 중복이 없는 정수형 배열(nums)과 찾는 수(target)가 주어진다. - 배열을 탐색하면서 target이 존재한다면 target의 index를 반환한다. - 만약 target이 없다면 target이 있어야 하는 위치의 index를 반환.. 2022. 4. 23. LeetCode 278(First Bad Version, java) 0. 문제 https://leetcode.com/problems/first-bad-version/ First Bad Version - 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. 문제 설명 - 문제에서 제품의 개수(= n)가 주어진다. - 모든 제품은 이전 버전의 제품을 기반으로 생성된다. - 그러므로 이전 버전이 잘못된 경우, 이를 기반으로 만들어진 다음 버전 또한 잘못된 제품이 된다. - 문제에서 isBadVersion(int version) 이라는 .. 2022. 4. 23. LeetCode 704(Binary Search, java) 0. 문제 https://leetcode.com/problems/binary-search/ Binary Search - 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. 문제 설명 - 문제에서 정수로 이루어진 배열(nums)과 찾는 수(target)가 주어진다. - O(log n)의 시간 복잡도로 탐색을 수행하여 배열에 있는 target의 존재 유무를 파악하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - O(log n)의 시간 복잡도로 탐색을.. 2022. 4. 23. 24. JPQL - 프로젝션(Projection, Select) 0. 개요 - 이번 포스팅에서는 JPQL을 이용하여 Select 절을 작성하는 방법에 대해서 알아보자. 1. 프로젝션(= projection) - 프로젝션이란 JPQL의 Select 절을 이용하여 어떤 데이터를 조회할 것인가를 말한다. - Select를 절의 조회 대상을 무엇으로 작성하냐에 따라 프로젝션의 종류가 달라진다. - 프로젝션은 조회하는 데이터의 속성에 따라서 다음 3가지 종류로 구분된다. → Entity(객체) 프로젝션 → Embedded 프로젝션 → 스칼라 프로젝션 2. Entity 프로젝션 a) Entity 프로젝션이란? - 객체 또는 객체의 속성을 조회하는 Select문을 말한다. b) 기본 사용방법 - 다음 예시를 보면서 이해해보자. - 첫 번째 예시는 객체를 조회하는 프로젝션이다. -.. 2022. 4. 22. LeetCode 235(Lowest Common Ancestor of a Binary Search Tree, java) 0. 문제 https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/ Lowest Common Ancestor of 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)와 두 개의 노드(p, q)가 주어진다. - 주어진 두 개의 노드(p, q) 사이에 존재하는 노드 중 가장 작은 값을 가지는 노.. 2022. 4. 22. LeetCode 653(Two Sum IV - Input is a BST, java) 0. 문제 https://leetcode.com/problems/two-sum-iv-input-is-a-bst/ Two Sum IV - Input is a BST - 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)와 찾는 수(k)가 주어진다. - 트리를 구성하는 노드 중 2개 노드의 value 합이 찾는 수인 경우가 존재하는지 판단하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 우선 모든 .. 2022. 4. 22. LeetCode 98(Validate Binary Search Tree, java) 0. 문제 https://leetcode.com/problems/validate-binary-search-tree/ Validate 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)가 주어진다. - 주어진 이진트리가 이진 탐색 트리를 만족하는지 판단하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 이 문제는 이진 탐색 트리의 조건을 만족하는지를 판단하는 문제다. .. 2022. 4. 22. 23. JPQL - 기본 기능(파라미터 바인딩, 결과 조회, 쿼리의 종류) 0. 개요 - 이전 포스팅에서 JPQL에 대해서 전반적으로 알아보았다. - 이번 포스팅에서는 JPQL의 기본 문법과 기능에 대해서 알아보자. 1. 기본 규칙 - JPQL은 다음과 같은 기본 규칙을 준수해야 한다. 1. JPQL은 DB 테이블이 아닌 객체(= Entity)를 대상으로 작성한다. 2. Entity를 사용할 때에는 테이블 명칭이 아닌 Entity 이름을 사용한다. 3. Entity 속성을 작성할 때, 대소문자를 구분하므로 주의해야 한다. 4. JPQL 키워드(= select, from, where 등)는 대소문자를 구분하지 않는다. 5. 별칭은 필수로 사용하며, as는 생략 가능하다. 2. 집합과 정렬 - JPQL은 ANSI 표준에 의해 정의된 SQL 문법을 모두 지원한다. - 집합과 정렬에는.. 2022. 4. 21. LeetCode 701(Insert into a Binary Search Tree, java) 0. 문제 https://leetcode.com/problems/insert-into-a-binary-search-tree/ Insert into 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)가 주어진다. - 이 문제는 문제에서 주어진 정수(= val)를 이진탐색트리에 삽입하는 것이 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 이진 탐색 트리.. 2022. 4. 21. 이전 1 ··· 3 4 5 6 7 8 9 ··· 42 다음