Posts

Data Attributes

Framework/Library or Native? Convention or Specification?

In the development world there is so many frameworks and libraries that build on abstractions on top of other abstractions it gets hard to understand is this thing that I’m doing specific to the framework or library that I am using or …

Flavors of Controlled and …

Conventions of Controlled and Uncontrolled Components

Let’s quickly talk about some conventions that you might notice in frontend component libraries like Radix.

If you need a little more details you can take a look at My Old Post . Also a shout out to Hari’s post which helped things …

Uncontrolled/Controlled …

Note to the Reader

This post is not really meant for people discovering this concept for the first time. It’s really meant for people who have heard about it already but it still hasn’t clicked. Maybe they’ve tried to implement this concept themselves but it didn’t feel …

Ecto Associations I: …

Motivation

One thing that might not be intuitive at first is that associations work on the whole collection of data. You’ll see this mentioned in a few ways in the docs. They’ll usually say that methods like cast_assoc and put_assoc work with the full data or the work with the …

Why Keyword List

Intro

As an Elixir beginner Keyword Lists are one of the weird features of the language. Coming from other languages, you’d almost always think of map-like structure first. So there’s a gnawing feeling, why keyword list? We’ll start with the unique characteristics of keyword list …

Directional Dependence

Intro

While going over the Flatland Space Station problem it made me stumble to a pattern I have noticed before and wanted to talk more about it. In this problem you run into a situation where the decision you want to make is dependent on two choices. Intuitively these decisions are not hard but …

Power Set

Introduction

In this case we want to try all possible variations of the given array. To be more specific we want to try all possible combinations of all possible lengths. What we’re describing here is the power set.

There’s a great article that elaborates even further on this however I …

Non Divisible Subset I

Introduction

Hackkerank medium problems continue to be a challenge for me. In this problem that we’ll take a look at it was challenging due to the fact that the brute force method seemed fairly involved and the inability to make connections to solve this problem in a faster way. In this post …

Flip Matrix Brute Force

Introduction

Warning: Code may not be 100% compilable but it should be close. I was making changes along the way so although at one point it passed the test cases it might not now.

In our previous posts we learned how to reverse rows and columns which we can use to solve Flip Matrix in a brute …

Reversing rows and cols …

Introduction

I want to cover the Flipping the Matrix problem in a non optimal way in order to practice a few fundamentals that I think are important. In this post we’ll cover nested loops and list comprehensions and in the next post we will cover backtracking and combinations.

List …

2D Matrix One Liner

Introduction

Python can be a powerful language since it allows you to acheive a lot through a few lines of code. The example we’re taking a look at in this post is how to create an M x N matrix.

dp = [[1]*n for i in range(m)]

We’ll break this into two parts:

  1. Sequence Repetition
  2. List …

Word Break = Choosing …

Intro

In this post we’ll go over the popular leetcode problem Word Break. This posts focuses more on how this problem can be viewed as choosing partitions. I belive that at a first glance it seems like there is no connection between the two so it is a neat discovery to make. In the editorial …

Monotonic Stack/Queue …

Goal

Introduces you mainly to the Monotonic Stack in an intuitive way with code snippets included. This post should help you understand when to start thinking of using a monotonic stack.

Introduction

In some problems like next greater element you see this pattern where one value can trump many …

Processing Tax (Graph …

Goal

The goal of this blog is to discuss graph traversal algorithms and give a little more intuition between the flow of the actual code. The blog assumes you are already familiar with Breadth First Search (BFS) and Depth First Search (DFS) algorithms. I would always forget when do you add a node to …

Countdown Pattern

Introduction

This pattern is pretty rare but it’s easy to spot once you recognize it. Let’s take a look at two problems that have this pattern. It does not improve your time or space complexity but it makes the overall approach to the code a litte simpler.

Koko Eating Bananas …

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 …

The Nature of BST nodes …

Characteristics of the problem

  1. You can’t start out with the root (lowest common ancestor)
  2. This is really a traversal problem
  3. 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 …

Leetcode 91: Decode Ways …

Why I like this problem

https://leetcode.com/problems/decode-ways/
A lot of the canonical recursive problems you start out with have really simple code. Things that come to mind are https://leetcode.com/problems/fibonacci-number/, https://leetcode.com/problems/climbing-stairs/ and …