Was finally able to solve all four problems during a contest!

Rank 146 - LeetCode Weekly 120

I think the problems were easier this time around, but it feels good regardless. I started reading through SICP because I want to learn functional programming, and it has been bending my mind quite a bit.

I haven’t gotten through the book yet, but I think some of its ideas helped me this week.

Wishful Thinking

I was creating small functions which would be nice to have for each problem.

For the last problem, I created one which would precompute the “valid” neighbours for a cell in the grid (those which are zero valued). Having a name for this helped me quickly come up with an edge case during the final check: there might be no zero squares to walk over before reaching the final cell.