Terrible LeetCode in Kotlin:

Опубликовано: 29 Август 2026
на канале: Personal Finance with Raymond
33
0

Another day, another LeetCode question (for now). Today, I'm running through #417 Pacific Atlantic Water Flow. The problem provides an m by n matrix, with the expected result being a list of pairs that correspond to the coordinates of cells where water can flow to opposite corners of the matrix (Pacific and Atlantic Ocean)

I've done this problem in the past, but had forgotten the solution. My initial idea was to run a BFS at every cell, until either no more cells can be traversed or until the cell has reached both "oceans", but I decided in the middle that it may be faster instead to actually run a BFS from all tiles that touch the oceans initially. That is ultimately the solution that I went with.

I work in Kotlin as my LeetCode programming language because my current focus is on Android app development. Kotlin is interoperable with Java, so the solution should be relatively similar albeit with some more boilerplate checks for nulls and such.

Current Grind:
Grind75 list, 22 weeks/16 hours per week, [89/169]
(https://www.techinterviewhandbook.org...)

Chapters:
00:00 - Problem discussion, coding begins (BFS)