Number of Islands | LeetCode 200 | Programming Tutorials

preview_player
Показать описание
In this tutorial, I have explained Number of Islands LeetCode solution using Java. How to count number of islands using DFS (Depth First Search).

Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.

In this tutorial, I have discussed how we can solve this problem using DFS.

This problem is the day 17 challenge of LeetCode 30 day challenge.

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

@Programming Tutorials
Man I loved your explanation. It was so easy to understand.
Thank You.

siddhantkedia
Автор

I watched many other tutorials for this question before this video. None was as simple as yours. your explanations were so clear and simple to understnad. Thank you!!

ShiShiva
Автор

Hey, I solved it. It's working fine.

ravikumarray
Автор

Best Explanation and fastest of all videos

arpitsatnalika
Автор

Great video to explain the problem in simple terms!

vijayanand
Автор

Hi,
i've a question.
would you please help me out for solution?
Qsn.- Monk visits the land of Islands. There are a total of 8 islands numbered from S to G. Some pairs of islands are connected to each other by Bidirectional bridges running over water. Monk hates to cross these bridges as they require a lot of efforts. He is standing at Island #S and wants to reach the Island #G. Find the minimum the number of bridges that he shall have to cross, if he takes the optimal route.

i've also diagram could you tell me how i will share with you?

Its_Personal
Автор

Sir, You have made it very simple , Easy to understand the picture here....So you should have written your profile as "Simple Programming tutorials" not "programming tutorial" .

ThabiraGamingShorts
Автор

Thanks for the tutorial! Love your explanation- can you please do one on word search?

VarsatyL
Автор

Hey buddy, can you clarify why the space is O(1) rather than O(M*N)? I though space should be O(M*N), cuz we recursively call the dfs function. Am I right? Thank you.

NextGlobalization
Автор

Did all your test cases pass successfully ? Because, for me writing the same code resulted into 2/47 pass test cases.

ravikumarray