{"id":20178636,"url":"https://github.com/chanda-abdul/several-coding-patterns-for-solving-data-structures-and-algorithms-problems-during-interviews","last_synced_at":"2025-04-14T08:57:07.460Z","repository":{"id":37367881,"uuid":"473804138","full_name":"Chanda-Abdul/Several-Coding-Patterns-for-Solving-Data-Structures-and-Algorithms-Problems-during-Interviews","owner":"Chanda-Abdul","description":"Several Coding Patterns for Solving Data Structures and Algorithms Problems during Interviews","archived":false,"fork":false,"pushed_at":"2024-08-20T03:17:31.000Z","size":2417,"stargazers_count":2309,"open_issues_count":14,"forks_count":695,"subscribers_count":21,"default_branch":"main","last_synced_at":"2025-04-07T02:09:57.746Z","etag":null,"topics":["algorithms","coding-interviews","data-structures","grokking-coding-interview","grokking-dynamic-programming","interview-preparation","interview-questions","javascript","leetcode"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Chanda-Abdul.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-24T23:25:44.000Z","updated_at":"2025-04-06T16:33:31.000Z","dependencies_parsed_at":"2024-11-14T03:16:14.743Z","dependency_job_id":null,"html_url":"https://github.com/Chanda-Abdul/Several-Coding-Patterns-for-Solving-Data-Structures-and-Algorithms-Problems-during-Interviews","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chanda-Abdul%2FSeveral-Coding-Patterns-for-Solving-Data-Structures-and-Algorithms-Problems-during-Interviews","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chanda-Abdul%2FSeveral-Coding-Patterns-for-Solving-Data-Structures-and-Algorithms-Problems-during-Interviews/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chanda-Abdul%2FSeveral-Coding-Patterns-for-Solving-Data-Structures-and-Algorithms-Problems-during-Interviews/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chanda-Abdul%2FSeveral-Coding-Patterns-for-Solving-Data-Structures-and-Algorithms-Problems-during-Interviews/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Chanda-Abdul","download_url":"https://codeload.github.com/Chanda-Abdul/Several-Coding-Patterns-for-Solving-Data-Structures-and-Algorithms-Problems-during-Interviews/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248852120,"owners_count":21171839,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithms","coding-interviews","data-structures","grokking-coding-interview","grokking-dynamic-programming","interview-preparation","interview-questions","javascript","leetcode"],"created_at":"2024-11-14T02:22:06.918Z","updated_at":"2025-04-14T08:57:07.440Z","avatar_url":"https://github.com/Chanda-Abdul.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Several Coding Patterns for Solving Data Structures and Algorithms Problems during Interviews\n\nThese are my notes in \u003cb\u003eJavascript\u003c/b\u003e from a [course](https://www.educative.io/courses/grokking-the-coding-interview) that categorizes coding interview problems into a set of \u003cb\u003e16 patterns\u003c/b\u003e. \n\n|   |   |\n|---|---|\n| \u003cb\u003e[Pattern 1: Sliding Window](./✅%20%20Pattern%2001%20:%20Sliding%20Window.md)\u003c/b\u003e|\u003cb\u003e[Pattern 9: Two Heaps](./✅%20🙃%20Pattern%2009:%20Two%20Heaps.md)\u003c/b\u003e   |\n|\u003cb\u003e[Pattern 2: Two Pointer](./✅%20%20Pattern%2002:%20Two%20Pointers.md)\u003c/b\u003e|\u003cb\u003e[Pattern 10: Subsets](./✅%20%20Pattern%2010:%20Subsets.md)\u003c/b\u003e|\n|\u003cb\u003e[Pattern 3: Fast \u0026 Slow pointers](./✅%20%20Pattern%2003:%20Fast%20%26%20Slow%20pointers.md)\u003c/b\u003e|\u003cb\u003e[Pattern 11: Modified Binary Search](./✅%20%20Pattern%2011:%20Modified%20Binary%20Search.md)\u003c/b\u003e|\n|\u003cb\u003e[Pattern 4: Merge Intervals](./✅%20%20Pattern%2004%20:%20Merge%20Intervals.md)\u003c/b\u003e|\u003cb\u003e[Pattern 12: Bitwise XOR](./✅%20Pattern%2012:%20%20Bitwise%20XOR.md)\u003c/b\u003e|\n|\u003cb\u003e[Pattern 5: Cyclic Sort](./✅%20%20Pattern%2005:%20Cyclic%20Sort.md)\u003c/b\u003e|\u003cb\u003e[Pattern 13: Top 'K' Elements](./✅%20Pattern%2013:%20Top%20'K'%20Elements.md)\u003c/b\u003e|\n|\u003cb\u003e[Pattern 6: In-place Reversal of a LinkedList](./✅%20%20Pattern%2006:%20In-place%20Reversal%20of%20a%20LinkedList.md)\u003c/b\u003e|\u003cb\u003e[Pattern 14: K-way merge](./%E2%9C%85%20Pattern%2014%3A%20K-way%20merge.md)\u003c/b\u003e|\n|\u003cb\u003e[Pattern 7: Tree Breadth First Search](./✅%20%20Pattern%2007:%20Tree%20Breadth%20First%20Search.md)\u003c/b\u003e|\u003cb\u003e[Pattern 15: 0/1 Knapsack (Dynamic Programming)](./%E2%9C%85%20Pattern%2015:%200-1%20Knapsack%20(Dynamic%20Programming).md)\u003c/b\u003e|\n|\u003cb\u003e[Pattern 8: Depth First Search (DFS)](./✅%20%20Pattern%2008:Tree%20Depth%20First%20Search.md)\u003c/b\u003e|\u003cb\u003e[Pattern 16: Topological Sort (Graph)](./%E2%9C%85%20Pattern%2016%3A%20%F0%9F%94%8E%20Topological%20Sort%20(Graph).md)\u003c/b\u003e|\n\n## Additional Resources\nHere are a few other resources that I found helpful when learning \u003cb\u003eData Structures and Algorithms\u003c/b\u003e using \u003cb\u003eJavaScript\u003c/b\u003e\n\n- [Run JS](https://runjs.app/) - A JavaScript playground\nfor your desktop\n- [Big O CheatSheet](https://www.bigocheatsheet.com/) - Reference for \u003cb\u003eBig-O\u003c/b\u003e complexities of common algorithms\n- [Blind 75](https://www.teamblind.com/post/New-Year-Gift---Curated-List-of-Top-75-LeetCode-Questions-to-Save-Your-Time-OaM1orEU) - For additional practice, the [Blind75 list](https://www.teamblind.com/post/New-Year-Gift---Curated-List-of-Top-75-LeetCode-Questions-to-Save-Your-Time-OaM1orEU) of interview questions is 🔥.  I would approach the questions in [this order](https://www.techinterviewhandbook.org/best-practice-questions) or [this order](https://neetcode.io/) or [create a custom Blind75 study plan](https://www.techinterviewhandbook.org/grind75)\n- [Edabit](https://edabit.com/) is a great resource if you need additional \u003cb\u003eJavascript\u003c/b\u003e practice before you start using \u003cb\u003eleetcode\u003c/b\u003e.\n- [LeetCode](https://leetcode.com/problemset/all/) of course\n😋\n- [Pramp](https://www.pramp.com/) - for mock interviews\n- [FreeCodeCamp's Algorithms](https://www.freecodecamp.org/learn/coding-interview-prep/#algorithms) - Extra practice, esp. the \u003cb\u003eSort Algorithms\u003c/b\u003e section.\n- [Build 15 JavaScript Projects - Vanilla JavaScript Course](https://www.youtube.com/watch?v=3PHXvlpOkf4) - for extra \u003cb\u003eVanilla JavaScript/DOM Manipulation\u003c/b\u003e practice.\n# \n#### 🌟 Challenge Questions\n\n#### 👩🏽‍🦯 Questions from \u003cb\u003e[Blind 75](https://www.teamblind.com/post/New-Year-Gift---Curated-List-of-Top-75-LeetCode-Questions-to-Save-Your-Time-OaM1orEU)\u003c/b\u003e\n\n#### 😐📖 Questions tagged \u003cb\u003eFaceBook/Meta\u003c/b\u003e\n\n#### 🌴 Questions tagged \u003cb\u003eAmazon\u003c/b\u003e\n\n#### 🔎 Questions tagged \u003cb\u003eGoogle\u003c/b\u003e\n## [Pattern 1: Sliding Window](./✅%20%20Pattern%2001%20:%20Sliding%20Window.md)\n\nIn many problems dealing with an array (or a \u003cb\u003eLinkedList\u003c/b\u003e), we are asked to find or calculate something among all the contiguous subarrays (or sublists) of a given size. For example, take a look at this problem:\n\n\u003e Given an array, find the average of all contiguous subarrays of size `K` in it.\n\nLets understand this problem with a real input:\n\n`Array: [1, 3, 2, 6, -1, 4, 1, 8, 2], K=5`\n\nA \u003cb\u003ebrute-force\u003c/b\u003e algorithm will calculate the sum of every 5-element contiguous subarray of the given array and divide the sum by 5 to find the average.\n\nThe efficient way to solve this problem would be to visualize each contiguous subarray as a sliding window of `5` elements. This means that we will slide the window by one element when we move on to the next subarray. To reuse the sum from the previous subarray, we will subtract the element going out of the window and add the element now being included in the sliding window. This will save us from going through the whole subarray to find the sum and, as a result, the algorithm complexity will reduce to `O(N)`.\n\n## [Pattern 2: Two Pointer](./✅%20%20Pattern%2002:%20Two%20Pointers.md)\n\nIn problems where we deal with sorted arrays (or \u003cb\u003eLinkedList\u003c/b\u003es) and need to find a set of elements that fulfill certain constraints, the [Two Pointers](./✅%20%20Pattern%2002:%20Two%20Pointers.md) approach becomes quite useful. The set of elements could be a pair, a triplet or even a subarray. For example, take a look at the following problem:\n\n\u003e Given an array of sorted `numbers` and a `target` sum, find a pair in the array whose sum is equal to the given `target`.\n\nTo solve this problem, we can consider each element one by one (pointed out by the first pointer) and iterate through the remaining elements (pointed out by the second pointer) to find a pair with the given sum. The time complexity of this algorithm will be `O(N^2)` where `n` is the number of elements in the input array.\n\nGiven that the input array is sorted, an efficient way would be to start with one pointer in the beginning and another pointer at the end. At every step, we will see if the numbers pointed by the \u003cb\u003e two pointers\u003c/b\u003e add up to the target sum. If they do not, we will do one of two things:\n1. If the sum of the two numbers pointed by the \u003cb\u003e two pointers\u003c/b\u003e is greater than the target sum, this means that we need a pair with a smaller sum. So, to try more pairs, we can decrement the end-pointer.\n2. If the sum of the two numbers pointed by the \u003cb\u003e two pointers\u003c/b\u003e is smaller than the target sum, this means that we need a pair with a larger sum. So, to try more pairs, we can increment the start-pointer.\n\n## [Pattern 3: Fast \u0026 Slow pointers](./✅%20%20Pattern%2003:%20Fast%20%26%20Slow%20pointers.md)\n\nThe \u003cb\u003eFast \u0026 Slow\u003c/b\u003e pointer approach, also known as the \u003cb\u003eHare \u0026 Tortoise algorithm\u003c/b\u003e, is a pointer algorithm that uses \u003cb\u003e two pointers\u003c/b\u003e which move through the array (or sequence/\u003cb\u003eLinkedList\u003c/b\u003e) at different speeds. This approach is quite useful when dealing with cyclic \u003cb\u003eLinkedList\u003c/b\u003es or arrays.\n\nBy moving at different speeds (say, in a cyclic \u003cb\u003eLinkedList\u003c/b\u003e), the algorithm proves that the \u003cb\u003e two pointers\u003c/b\u003e are bound to meet. The \u003ci\u003efast pointer\u003c/i\u003e should catch the \u003ci\u003eslow pointer\u003c/i\u003e once both the pointers are in a cyclic loop.\n\nOne of the famous problems solved using this technique was [Finding a cycle in a \u003cb\u003eLinkedList\u003c/b\u003e](https://github.com/Chanda-Abdul/Several-Coding-Patterns-for-Solving-Data-Structures-and-Algorithms-Problems-during-Interviews/blob/main/%E2%9C%85%20%20Pattern%2003:%20Fast%20%26%20Slow%20pointers.md#linkedlist-cycle-easy). Lets jump onto this problem to understand the \u003cb\u003eFast \u0026 Slow\u003c/b\u003e pattern.\n\n## [Pattern 4: Merge Intervals](./✅%20%20Pattern%2004%20:%20Merge%20Intervals.md)\n\nThis pattern describes an efficient technique to deal with overlapping intervals. In a lot of problems involving intervals, we either need to find overlapping intervals or merge intervals if they overlap.\n\nGiven two intervals (`a` and `b`), there will be six distinct ways the two intervals can relate to each other:\n1. `a` and `b`do not overlap\n2. `a` and `b` overlap, `b` ends after `a`\n3. `a` completely overlaps `b`\n4. `a` and `b` overlap, `a` ends after `b`\n5. `b` completly overlaps `a`\n6. `a` and `b` do not overlap\n\nUnderstanding the above six cases will help us in solving all intervals related problems.\n![](./images/mergeintervals.png)\n\n## [Pattern 5: Cyclic Sort](./✅%20%20Pattern%2005:%20Cyclic%20Sort.md)\n\nThis pattern describes an interesting approach to deal with problems involving arrays containing numbers in a given range. For example, take the following problem:\n\n\u003eYou are given an unsorted array containing numbers taken from the range `1` to `n`. The array can have duplicates, which means that some numbers will be missing. Find all the missing numbers.\n\nTo efficiently solve this problem, we can use the fact that the input array contains numbers in the range of `1` to `n`. \nFor example, to efficiently sort the array, we can try placing each number in its correct place, i.e., placing `1` at index `0`, placing `2` at index `1`, and so on. Once we are done with the sorting, we can iterate the array to find all indices that are missing the correct numbers. These will be our required numbers.\n\n## [Pattern 6: In-place Reversal of a LinkedList](./✅%20%20Pattern%2006:%20In-place%20Reversal%20of%20a%20LinkedList.md)\n\nIn a lot of problems, we are asked to reverse the links between a set of nodes of a \u003cb\u003eLinkedList\u003c/b\u003e. Often, the constraint is that we need to do this \u003ci\u003ein-place\u003c/i\u003e, i.e., using the existing node objects and without using extra memory.\n\n\u003cb\u003e\u003ci\u003ein-place\u003c/i\u003e Reversal of a \u003cb\u003eLinkedList\u003c/b\u003e pattern\u003c/b\u003e describes an efficient way to solve the above problem.\n\n## [Pattern 7: Tree Breadth First Search](./✅%20%20Pattern%2007:%20Tree%20Breadth%20First%20Search.md)\nThis pattern is based on the \u003cb\u003eBreadth First Search (BFS)\u003c/b\u003e technique to traverse a tree.\n\nAny problem involving the traversal of a tree in a level-by-level order can be efficiently solved using this approach. We will use a \u003cb\u003eQueue\u003c/b\u003e to keep track of all the nodes of a level before we jump onto the next level. This also means that the space complexity of the algorithm will be `O(W)`, where `W` is the maximum number of nodes on any level.\n\n## [Pattern 8: Depth First Search (DFS)](./✅%20%20Pattern%2008:Tree%20Depth%20First%20Search.md)\n\nThis pattern is based on the \u003cb\u003eDepth First Search (DFS)\u003c/b\u003e technique to traverse a tree.\n\nWe will be using recursion (or we can also use a stack for the iterative approach) to keep track of all the previous (parent) nodes while traversing. This also means that the space complexity of the algorithm will be `O(H)`, where `H` is the maximum height of the tree.\n\n## [Pattern 9: Two Heaps](./✅%20🙃%20Pattern%2009:%20Two%20Heaps.md)\n\nIn many problems, where we are given a set of elements such that we can divide them into two parts. To solve the problem, we are interested in knowing the smallest element in one part and the biggest element in the other part. This pattern is an efficient approach to solve such problems.\n\nThis pattern uses two \u003cb\u003eHeaps\u003c/b\u003e to solve these problems; A \u003cb\u003eMin Heap\u003c/b\u003e to find the smallest element and a \u003cb\u003eMax Heap\u003c/b\u003e to find the biggest element.\n\u003c!-- ### ❗ NOTE\n\nAlthough this course uses \u003cb\u003eHeaps\u003c/b\u003e to solve \u003cb\u003eTop 'K' Elements\u003c/b\u003e problems, \u003cb\u003eJavaScript\u003c/b\u003e does not have a built in method for \u003cb\u003eHeaps/Priority Queues\u003c/b\u003e. It can be very time consuming to implement a \u003cb\u003eHeap class\u003c/b\u003e from scratch, especially during an interview. After reviewing the \u003ci\u003eJavaScript\u003c/i\u003e solutions on \u003ci\u003eLeetcode\u003c/i\u003e the most effecient way to solve a \u003cb\u003eTop 'K' Elements\u003c/b\u003e problem is usually with \u003cb\u003e[QuickSort](https://github.com/Chanda-Abdul/leetcode/blob/master/0%20%E2%9D%97Sort%20Algorithms.md#-quick-sort)\u003c/b\u003e, \u003cb\u003e[BinarySearch](https://github.com/Chanda-Abdul/leetcode/blob/master/0%20%E2%9D%97Sort%20Algorithms.md#binary-search)\u003c/b\u003e, \u003cb\u003e[BucketSort](https://initjs.org/bucket-sort-in-javascript-dc040b8f0058)\u003c/b\u003e, \u003cb\u003e[Greedy Algorithms](https://github.com/Chanda-Abdul/Grokking-Algorithm-Book-Notes/blob/main/8.%20Greedy%20Algoritms.md)\u003c/b\u003e, or \u003cb\u003e[HashMaps](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)\u003c/b\u003e.  --\u003e\n\n## [Pattern 10: Subsets](./✅%20%20Pattern%2010:%20Subsets.md)\n\nA huge number of coding interview problems involve dealing with \u003cb\u003ePermutations\u003c/b\u003e and \u003cb\u003eCombinations\u003c/b\u003e of a given set of elements. This pattern describes an efficient \u003cb\u003eBreadth First Search (BFS)\u003c/b\u003e approach to handle all these problems.\n\n## [Pattern 11: Modified Binary Search](./✅%20%20Pattern%2011:%20Modified%20Binary%20Search.md)\n\nAs we know, whenever we are given a sorted \u003cb\u003eArray\u003c/b\u003e or \u003cb\u003eLinkedList\u003c/b\u003e or \u003cb\u003eMatrix\u003c/b\u003e, and we are asked to find a certain element, the best algorithm we can use is the \u003cb\u003eBinary Search\u003c/b\u003e.\n## [Pattern 12: Bitwise XOR](./✅%20Pattern%2012:%20%20Bitwise%20XOR.md)\n\n\u003cb\u003eXOR\u003c/b\u003e is a logical bitwise operator that returns `0` (false) if both bits are the same and returns `1` (true) otherwise. In other words, it only returns `1` if exactly one bit is set to `1` out of the two bits in comparison.\n\n## [Pattern 13: Top 'K' Elements](./✅%20Pattern%2013:%20Top%20'K'%20Elements.md)\n\nAny problem that asks us to find the \u003cb\u003etop/smallest/frequent `K` elements\u003c/b\u003e among a given set falls under this pattern.\n\n\n\u003c!-- ### ❗ NOTE\n\nAlthough this course uses \u003cb\u003eHeaps\u003c/b\u003e to solve \u003cb\u003eTop 'K' Elements\u003c/b\u003e problems, \u003cb\u003eJavaScript\u003c/b\u003e does not have a built in method for \u003cb\u003eHeaps/Priority Queues\u003c/b\u003e. It can be very time consuming to implement a \u003cb\u003eHeap class\u003c/b\u003e from scratch, especially during an interview. After reviewing the \u003ci\u003eJavaScript\u003c/i\u003e solutions on \u003ci\u003eLeetcode\u003c/i\u003e the most effecient way to solve a \u003cb\u003eTop 'K' Elements\u003c/b\u003e problem is usually with \u003cb\u003e[QuickSort](https://github.com/Chanda-Abdul/leetcode/blob/master/0%20%E2%9D%97Sort%20Algorithms.md#-quick-sort)\u003c/b\u003e, \u003cb\u003e[BinarySearch](https://github.com/Chanda-Abdul/leetcode/blob/master/0%20%E2%9D%97Sort%20Algorithms.md#binary-search)\u003c/b\u003e, \u003cb\u003e[BucketSort](https://initjs.org/bucket-sort-in-javascript-dc040b8f0058)\u003c/b\u003e, \u003cb\u003e[Greedy Algorithms](https://github.com/Chanda-Abdul/Grokking-Algorithm-Book-Notes/blob/main/8.%20Greedy%20Algoritms.md)\u003c/b\u003e, or \u003cb\u003e[HashMaps](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)\u003c/b\u003e.  --\u003e\n\n## [Pattern 14: K-way merge](./%E2%9C%85%20Pattern%2014%3A%20K-way%20merge.md)\nThis pattern helps us solve problems that involve a list of sorted arrays.\n\nWhenever we are given `K` sorted arrays, we can use a \u003cb\u003eHeap\u003c/b\u003e to efficiently perform a sorted traversal of all the elements of all arrays. We can push the smallest (first) element of each sorted array in a \u003cb\u003eMin Heap\u003c/b\u003e to get the overall minimum. While inserting elements to the \u003cb\u003eMin Heap\u003c/b\u003e we keep track of which array the element came from. We can, then, remove the top element from the heap to get the smallest element and push the next element from the same array, to which this smallest element belonged, to the heap. We can repeat this process to make a sorted traversal of all elements.\n\u003c!-- ### ❗ NOTE\n\nAlthough this course uses \u003cb\u003eHeaps\u003c/b\u003e to solve \u003cb\u003eTop 'K' Elements\u003c/b\u003e problems, \u003cb\u003eJavaScript\u003c/b\u003e does not have a built in method for \u003cb\u003eHeaps/Priority Queues\u003c/b\u003e. It can be very time consuming to implement a \u003cb\u003eHeap class\u003c/b\u003e from scratch, especially during an interview. After reviewing the \u003ci\u003eJavaScript\u003c/i\u003e solutions on \u003ci\u003eLeetcode\u003c/i\u003e the most effecient way to solve a \u003cb\u003eTop 'K' Elements\u003c/b\u003e problem is usually with \u003cb\u003e[QuickSort](https://github.com/Chanda-Abdul/leetcode/blob/master/0%20%E2%9D%97Sort%20Algorithms.md#-quick-sort)\u003c/b\u003e, \u003cb\u003e[BinarySearch](https://github.com/Chanda-Abdul/leetcode/blob/master/0%20%E2%9D%97Sort%20Algorithms.md#binary-search)\u003c/b\u003e, \u003cb\u003e[BucketSort](https://initjs.org/bucket-sort-in-javascript-dc040b8f0058)\u003c/b\u003e, \u003cb\u003e[Greedy Algorithms](https://github.com/Chanda-Abdul/Grokking-Algorithm-Book-Notes/blob/main/8.%20Greedy%20Algoritms.md)\u003c/b\u003e, or \u003cb\u003e[HashMaps](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)\u003c/b\u003e.  --\u003e\n## [Pattern 15: 0/1 Knapsack (Dynamic Programming)](./%E2%9C%85%20Pattern%2015:%200-1%20Knapsack%20(Dynamic%20Programming).md)\n\u003cb\u003e0/1 Knapsack pattern\u003c/b\u003e is based on the famous problem with the same name which is efficiently solved using \u003cb\u003eDynamic Programming (DP)\u003c/b\u003e.\n\nIn this pattern, we will go through a set of problems to develop an understanding of \u003cb\u003eDP\u003c/b\u003e. We will always start with a \u003cb\u003ebrute-force\u003c/b\u003e recursive solution to see the overlapping subproblems, i.e., realizing that we are solving the same problems repeatedly.\n\nAfter the recursive solution, we will modify our algorithm to apply advanced techniques of \u003cb\u003eMemoization\u003c/b\u003e and \u003cb\u003eBottom-Up Dynamic Programming\u003c/b\u003e to develop a complete understanding of this pattern.\n\n## [Pattern 16: 🔎 Topological Sort (Graph)](./%E2%9C%85%20Pattern%2016%3A%20%F0%9F%94%8E%20Topological%20Sort%20(Graph).md)\n\u003cb\u003eTopological Sort\u003c/b\u003e is used to find a linear ordering of elements that have dependencies on each other. For example, if event `B` is dependent on event `A`, `A` comes before `B` in topological ordering.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanda-abdul%2Fseveral-coding-patterns-for-solving-data-structures-and-algorithms-problems-during-interviews","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchanda-abdul%2Fseveral-coding-patterns-for-solving-data-structures-and-algorithms-problems-during-interviews","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanda-abdul%2Fseveral-coding-patterns-for-solving-data-structures-and-algorithms-problems-during-interviews/lists"}