Number of Islands (Medium) - Daily Leetcode 200 - Day 3 - Solve with Sam in Python

preview_player
Показать описание

_Note 1: At 2:32 I say and use the term 'waterfall' algorithm, but the correct/common naming is 'floodfill' algorithm._

_Note 2: Removing the set() visited and solely using the grid replacing island cells with water in place has a slight speed improvement, so if modifying the original array is allowed this is a good strategy._

00:00 - Intro
02:17 - Discuss approaches
06:47 - Start solve
23:36 - Test on leetcode
29:21 - Discussion / Attempted optimizations

Рекомендации по теме
Комментарии
Автор

I would suggest you to zoom in more cause I always have to zoom in on your videos. I like how you approach new problems and really like the process. I'm currently having difficulty on the problem strong password check. Can you go over that one in the future?

tinle
Автор

I did this one kind of easily, but the performance statistics showed that my solution outperformed only 17% out them of all. Lol :) Instead of a set I used a 2d-array to mark visited cells. And I think the faster approach here would be to modify the original grid.

ombieautopilot
visit shbcf.ru