Posts

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 …

The Nature of BST nodes …

Characteristics of the problem You can’t start out with the root (lowest common ancestor) This is really a traversal problem Each node has a range of values that it could contain which is from [min(leftSubtree), max(rightSubtree)]. Understanding this range means we know the possible children …

Intuitive Proof for …

Introduction I found a few resources that I think did a decent job at explaining bits and pieces but not the full thing. This is also a tool for me to think things through as I go through the proof. Leetcode solution with useful insights Math stackexchange with useful insights Neetcode’s …