본문 바로가기

Algorithm/알고리즘 문제풀이92

LeetCode 19(Remove Nth Node From End of List, java) 0. 문제 https://leetcode.com/problems/remove-nth-node-from-end-of-list/ Remove Nth Node From End of List - 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)와 정수(n)가 주어진다. - 연결 리스트를 탐색하여 뒤에서부터 n번째에 위치한 노드를 삭제하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 가장 먼저 떠오르는 방.. 2022. 4. 26.
LeetCode 876(Middle of the Linked List, java) 0. 문제 https://leetcode.com/problems/middle-of-the-linked-list/ Middle of the Linked List - 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개라면 두 번째 중간 노드를 반환한다. 2. 문제 해설 a) 첫 번째 접근 - 이 .. 2022. 4. 26.
LeetCode 557(Reverse Words in a String III, java) 0. 문제 https://leetcode.com/problems/reverse-words-in-a-string-iii/ Reverse Words in a String III - 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)이 주어진다. - 해당 문자열은 공백을 포함한 여러 개의 단어로 이루어져 있다. - 단어 단위로 역순으로 정렬하는 것이 문제의 핵심이다. 2. 문제 해설 - 어떤 문제를 푸는 방식은 다양하지만, 이 문제.. 2022. 4. 25.
LeetCode 344(Reverse String, java) 0. 문제 https://leetcode.com/problems/reverse-string/ Reverse 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. 문제 설명 - 문제에서 문자형 배열(char[] s)가 주어진다. - O(1)의 시간 복잡도를 가지는 추가 메모리만을 사용하여 s를 역순으로 정렬하는 것이 문제의 핵심이다. - 여기서 O(1)의 시간 복잡도를 가지는 추가 메모리가 의미하는 것은 기본 자료형을 사용하는 변수를 의미한다. - .. 2022. 4. 25.
LeetCode 167(Two Sum II - Input Array Is Sorted, java 0. 문제 https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/ Two Sum II - Input Array Is Sorted - 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. 문제 설명 - 문제에서 오름차순으로 정렬된 정수형 배열(numbers)과 찾는 수(target)가 주어진다. - 배열을 탐색하여 두 요소의 합이 target을 이루는 짝을 찾고, 두 요소가 몇 번째 숫자인지 배열에 담아 반.. 2022. 4. 25.
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.