Posts

Choose Unchoose Pattern …

Introduction

This is part two of my discussion on the choose unchoose pattern found in programming interview questions. This post will specifically focus on the loop aspect of the pattern. We will use the Combination Sub problem as the application to the concepts.

Understanding why a loop also works …

Stable Sort = Complex …

Introduction

Sometimes you learn the hard way in life. Con is that there was a potential cost. On the plus side you will likely not forget it. In today’s topic is brought to you by me taking twice as long to complete my interview assessment and potentially failing it for that reason. So the …

01 Matrix (BFS with …

Introduction

We’re taking a look at 01 Matrix on Leetcode today. The main motivation is to realize that when using BFS you can start with multiple sources instead of a single source. This just means that even though we usually start out with a “root” and do BFS from there, you can …

Insert Interval

Introduction

Today we’ll take a look at Insert Interval. The reason why I think this is a useful problem to learn is because it helps you approach these problems in such a way where the code is more intuitive. Essentially the reasoning behind this problem and others like it is that it is not …

01 Matrix (Solving DP by …

Trouble

Even if you traverse the node wouldn’t you need to traverse the node for every node. For each node we’d need to determine the distance by traversing it? Multiple traversals are costly

A Dynamic Programming solution comes into play. Ask your neighbor what is the distance to 0 from …

Work Smarter not Harder …

Introduction

After some time working on Leetcode you start to realize trends in the problem. One category that I have recognized is one where the “elegant” solution uses simple logic to narrow out work.

Brute Force

Create a sliding window with the size of minSize. One of the rules that …