Close-up of growth rings in a thick tree stump

Interval Algorithm Summaries

Here are the Blind 75 Interval Algorithm Summaries. An “Interval” data structure for the purpose of these Leetcode problems just means an array of Pairs, where each one represents a range of numbers. Insert Interval Given an array of non-overlapping sorted interval ranges, add the new input interval range so that the result is still sorted and non-overlapping. Solution with O(N) time / O(N) space Create a new array to hold the result. Iterate through the array of interval ranges: ...

August 10, 2024 · 3 min
photo of outer space

Graph Algorithm Summaries

Here are the Blind 75 Graph Algorithm Summaries. Graph data structures are used to represent relationships between data. The graph is composed of Nodes and Edges, where the Node holds some piece of data, and Edges connect Nodes together either with a directed or undirected relationship. Clone Graph Given a node from a connected graph, return a copy of the graph. Solution with O(N) Time / O(N) Space Recursively follow the starting node’s neighbors, making a copy of each node, and also saving the nodes to a hash map. When you encounter a node already in the hashmap, return the saved result. ...

July 26, 2024 · 4 min
three blue-and-yellow parrots on tree branch

Binary Algorithm Summaries

Continuing through the Blind 75 summarizations, here are the binary-related questions. There are not many tricks with these questions, this is just testing knowledge on binary operations. Sum of Two Integers Find sum of two integers without using built in integer operators. Solution with O(1)/O(1): Use binary operators: Take binary AND of the input integers, shift left 1, that is the carry Take binary XOR of the input integers, that is the result Recursively repeat with result and carry instead of the input integers, until the carry is 0 Number of 1 Bits Given an integer, return the number of 1 bits in its binary representation. ...

July 14, 2024 · 2 min
green and pink plastic container

Order or Chaos

The third chapter of Algorithms to Live By is about sorting. Some examples of sorting you might encounter: Ordering books on a shelf (if you still have physical ones) Participating in a tournament orders individuals/teams by skill (with varying degrees of reliability) Sorting food in your fridge so you know where to look for things With more digitization these days, computers will handle most of the mundane sorting like ordering documents, but it’s interesting to realize how we naturally follow some of these algorithms. Let’s take an example of ordering your todo list by priority: ...

July 7, 2024 · 3 min
Corn Field

Array Algorithm Summaries

For software developers, there’s some pride in being able to solve complex algorithm questions. Day to day development might not require the same level of complexity, but pushing your understanding of data structures and algorithms can give you the right tools to solve other problems with a balance of simplicity and efficiency. That’s why I wanted to check my understanding by summarizing the Leetcode Blind 75 problems and at least one solution. ...

June 30, 2024 · 4 min