목록알고리즘 (4)
허허의 오늘은 뭐 먹지?
이 문제는 전형적인 topological sort (위상정렬) 문제입니다. leetcode.com/problems/course-schedule/ Course Schedule - 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 위키에 topological sort에 대해서 잘 설명되어 있습니다. ko.wikipedia.org/wiki/%EC%9C%84%EC%83%81%EC%A0%95%EB%A0%AC 위상정렬 - 위키백과, 우리 모두의 백과사전 위키백과, 우리 모두의..
DP와 관련된 문제입니다. leetcode.com/problems/partition-equal-subset-sum/ Partition Equal Subset 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 input이 [5, 11, 5, 1] 인 경우, [11], [5,5,1]로 그룹을 묶으면 두 그룹의 합이 같으므로 true를 리턴해야 합니다. 전체 값의 합이 22이므로, 어떤 수들의 합이 11이 되는지를 보면 됩니다. 처음으로 풀어본 것은 아래와 같..
겹치는 구간을 합치는 문제입니다. leetcode.com/problems/merge-intervals/ Merge Intervals - 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 이 문제의 핵심은 처리해야 할 구간 배열에 대해 정렬을 먼저 하는 것입니다. 시작 시간을 기준으로 입력된 값을 정렬합니다. 먼저 병합된 결과값을 저장하는 변수를 선언하고 정렬된 배열의 전체를 처음부터 탐색합니다. 만약에 병합된 결과값의 마지막으로 들어간 값의 종료시간보다 탐색 중인 ..
모든 Anagram을 찾는 문제입니다. https://leetcode.com/problems/find-all-anagrams-in-a-string/ Find All Anagrams in a 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 이 문제는 sliding window 알고리즘을 사용하는 대표적인 문제 중 하나입니다. 어떻게든 노가다로 문제를 풀 수는 있지만 sliding window를 사용하지 않는다면 좋은 성능으로 풀기 어려운 문제입니다...