LeetCode: Number of Islands

For the second entry in the LeetCode series, I will be discussing another medium-difficulty problem. However, unlike the in-depth analysis covered in the last LeetCode problem, this post will be a succinct overview of an efficient solution. This problem is great because it’s easily to visualize the input, and it does not have a lot of constraints. It also never hurts to have more practice with multidimensional arrays + graph searching algorithms....

November 22, 2021 · 3 min · Tyler Waters

Leetcode: Set Matrix Zeroes (Part 2)

Continuing where we left off last week, let’s finally dicuss the optimal solution to the Set Matrix Zeroes problem from LeetCode. If you have not read Part 1, please do so! In the previous post, we discussed the problem & constraints, as well as some intuition behind the solution. Building off of this intuition, let’s go over the algorithm! The Solution Recalling our constant-space requirement, and the conflicts that can come from writing zeroes before completing the first read, how can we safely indicate which rows and columns will be set to zero without compromising correctness?...

November 7, 2021 · 6 min · Tyler Waters

Leetcode: Set Matrix Zeroes (Part 1)

This problem, of medium difficulty, sounds trivial at first glance. However, given the constraints, it’s not as straightforward as it initially appears. The Problem The problems is set-up as seen here: Set Matrix Zeroes - LeetCode Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0’s, and return the matrix. You must do it in place. Constraints: m == matrix....

November 4, 2021 · 3 min · Tyler Waters