문제: https://programmers.co.kr/learn/courses/30/lessons/67256풀이: DFS를 쓸지, BFS를 쓸지 고민하다 거리 배열을 사용하면 좋겠다는 생각이 들었다.
이 포스팅을 작성하는 이유는 3Sum과 4Sum 문제를 풀기 위해서다.이 문제는 배열이 주어지고, 합이 target이 되는 원소 2개의 index를 반환하는 문제이다.최악의 경우 O(N^2)의 시간복잡도를 가진다. 설명은... 생략여기서부터 3Sum과 4Sum 문제를
문제 링크: https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/지난 번 작성한 Two Sum을 다르게 풀어보는 문제이다.input으론 정렬된 배열이 주어지고, 합이 target이 되는 두 원소를 찾
문제 링크: https://leetcode.com/problems/3sum/ Two Sum 과 Two Sum II 문제에 이어지는 문제이다. 배열이 주어지고, 합이 0이 되는 세 원소쌍들을 모두 찾아 반환하는 문제이다.문제 풀이에 들어가기 전에, Two Su
문제 링크: https://leetcode.com/problems/4sum/n개의 정수로 이루어진 배열이 주어지면, 배열 중 네 원소를 더해 target이 되는 부분집합들의 집합을 반환하는 문제이다.가장 먼저 떠오르는 방법은 재귀함수를 이용한 백트래킹이다.연속
문제 링크: https://leetcode.com/problems/longest-substring-without-repeating-characters/주어진 문자열에서 문자가 중복되지 않는 최대 길이 문자열의 길이를 반환하는 문제이다.Bruteforce 방법부
11. Container With Most Water
문제 링크: https://leetcode.com/problems/insertion-sort-list/아래와 같이 정의된 singly-linked list를 Insertion Sort를 이용해 정렬하는 문제이다.배열에서 insertion sort를 수행하는 것
Summary Ranges 문제 링크: https://leetcode.com/problems/summary-ranges/
문제 링크: https://leetcode.com/problems/course-schedule/들을 수 있는 수업의 개수인 numCourses가 주어지고, 선수 과목 쌍이 주어지면, 모든 수업을 수강할 수 있는지 그 여부를 반환하는 문제이다.즉, 방향이 있는
문제 링크: https://leetcode.com/problems/course-schedule-ii/
104. Maximum Depth of Binary Tree 문제 링크: https://leetcode.com/problems/maximum-depth-of-binary-tree/ Binary tree의 root가 주어지면, 해당 트리의 높이를 반환하는 문제이다.
559. Maximum Depth of N-ary Tree
문제 링크: https://leetcode.com/problems/minimum-height-trees/
897\. Increasing Order Search Tree