Recent Posts

TIW: Reverse Linked List

4 minute read

A linked list is an array that supports O(1) insertion and O(n) random access, in contrast to vector’s O(n) insertion and O(1) random access. Here’s how a li...

TIW: Dijkstra

4 minute read

Shortest path problems using Dijkstra are actually very easy to write. There is a fixed format and you just need to fill in the blanks. The format:

TIW: Monotonic Stack

6 minute read

I actually made this name up; I don’t know what it is called. This is how the Chinese call it apparently, 單調棧. It sometimes comes handy when you need O(n) pe...

TIW: BFS, DFS

7 minute read

Breadth First Search and Depth First Search are both essential skills to passing medium problems. If you’ve been following along, I’ve already written BFS on...

EE354 Project: Minesweeper in Verilog

3 minute read

Finished a project a few days ago for EE354 at USC: Introduction to Digital Circuits. The final project for the class requires us to write a program in veril...

Binary Search: A Better Way

7 minute read

So you think you know how to write binary search - just like everyone else. I mean, it’s easy, right? Maybe, but you can probably do it better. Let’s start w...

TIW: Range Sum

4 minute read

Prefix array sum is a useful tool that shows up often. It achieves the following:

TIW: Two Pointers

4 minute read

It’s quite surprising how much you can accomplish with constant extra space. There are a few classic problems with integer arrays that can be solved by two p...