Hasuer's Studio.

Hasuer's Studio.

it's better to burn out than to fade away

14. Pattern Two Heaps
IntroductionIn 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 proble...
13. Pattern Island (Matrix traversal)
Introduction to Island PatternMany coding interview problems involve traversing 2D arrays (aka matrix or grid). The Island pattern describes all the efficient ways to traverse a matrix. This pattern will go through many problems to explain matrix traversal using Depth First Search (DFS) and Bread...
12. Pattern Graphs
Introduction to GraphA graph is a data structure that consists of a set of vertices (nodes) and a bunch of edges connecting these vertices. Graphs are widely used to model real-world scenarios where relationships and connections between entities must be represented. A Graph G (V, E) with five ver...
11. Pattern Tree Depth First Search
IntroductionThis pattern is based on the Depth First Search (DFS) technique to traverse a tree. We 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 al...
10. Pattern Tree Breadth First Search
IntroductionThis pattern is based on the Breadth First Search (BFS) technique to traverse a tree. Any problem involving the traversal of a tree in a level-by-level order can be efficiently solved using this approach. We will use a Queue to keep track of all the nodes of a level before we jump ont...
9. Pattern Hash Maps
Introduction to HashingImagine you have a huge bookshelf (like, Hogwarts library size). You’ve got a new book and need to find a spot for it and later on, search it quickly every time you need it. Instead of scanning the whole shelf, you use a magical spell that tells you exactly where to place o...
8. Pattern Monotonic Stack
Introduction to Monotonic StackDefinition of Monotonic StackA Monotonic Stack is a special kind of stack, a common data structure in computer science, which maintains its elements in a specific order. Unlike a traditional stack, where elements are placed on top of one another based on when they a...
7. Pattern Stack
Introduction to StackStack is a linear data structure that follows a particular order of operation. This order can either be Last In First Out (LIFO) or First In Last Out (FILO). Imagine you have a pile of books that you plan to read. You keep adding books to the top of the pile. When you’re read...
6. Pattern In-place Reversal of a LinkedList
IntroductionIn a lot of problems, we are asked to reverse the links between a set of nodes of a LinkedList. Often, the constraint is that we need to do this in-place, i.e., using the existing node objects and without using extra memory. In-place Reversal of a LinkedList pattern describes an effic...
5. Pattern Cyclic Sort
IntroductionThis pattern describes an interesting approach to deal with problems involving arrays containing numbers in a given range. For example, take the following problem: You are given an unsorted array containing n numbers taken from the range 1 to n. The array can have duplicates, which m...
avatar
Hasuer
witness me