본문 바로가기

Algorithm120

LeetCode 733(Flood Fill, java) 0. 문제 https://leetcode.com/problems/flood-fill/ Flood Fill - 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. 문제 설명 - 문제에서 이중 배열(image)과 시작점이 되는 row(= sr)와 column(= sc) 위치, 새로운 색상(= newColor)이 주어진다. - 문제에서 제공하는 시작 위치의 값과 시작 위치를 기준으로 4방향에 존재하는 요소의 값이 동일하다면, 해당 요소의 값을 newColor로 대체하.. 2022. 4. 27.
LeetCode 567(Permutation in String, java) 0. 문제 https://leetcode.com/problems/permutation-in-string/ Permutation in 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. 문제 설명 - 문제에서 2개의 문자열(s1, s2)이 주어진다. - s1을 구성하는 문자의 순열 중 하나라도 s2를 구성한다면 true를 반환하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 우선 순열을 어떻게 구할 것인지에 대해서 생각해보자. -.. 2022. 4. 27.
LeetCode 3(Longest Substring Without Repeating Characters, java) 0. 문제 https://leetcode.com/problems/longest-substring-without-repeating-characters/ Longest Substring Without Repeating Characters - 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. 문제 해설 a) 첫 번째 접근.. 2022. 4. 26.
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.