728x90 반응형 memoization3 Dynamic Programming _ Memoization 설명 및 적용 #1 Why ? What is Dynamic Programming? 🧐 피보나치수열 예시 _ const fib = (n) => { if (n { if (n in memo) return memo[n]; if (n { if (m === 1&& n === 1) return 1; if (m === 0 || n === 0) return 0; return gridTraveler(m-1,n) + gridTraveler(m,n-1); }; 하지만 이 코드는 time complexity로 비효율적이라는 단점이 있는데요 어떤 부분이 겹치는지, 효율성이 개선될 수 있는지 보면 사실상 gridTraveler(a,b) = gridTraveler(b,a) 로 계산을 중복으로 할 필요가 없음을 알게됩니다 이 부분에 memoization.. 2022. 10. 6. Leetcode 416. Partition Equal Subset Sum https://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 이 문제는 처음에 만만하게 보고 간단한 코드를 짰다가 에러가 나서 애를 먹은 문제입니다 ㅜㅠ 여러 풀이를 보면서 어떤 식으로 해결 될 수 있는지 보겠습니다. Brute-Force class Solution: def canPartition(self, nums): d.. 2022. 10. 4. Leetcode 139. Word Break (Trie, BFS, DP) https://leetcode.com/problems/word-break/ Word Break - 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 이전에 Trie의 개념과 기본 구조를 다루는 문제를 풀었었는데요 2022.09.27 - [Data Structure & Algorithm] - Trie (트라이, Digital tree, prefix, Retrieval tree) + 예제 코드 Trie (트라이, Digital tree, prefix, Retrieval.. 2022. 10. 3. 이전 1 다음 728x90 반응형