Solving Graph Problems — Number of Islands

Let’s solve the famous Number of Islands Problem and its various similar problems.

Kumar Shubham
CodeX

--

Photo by Tom Winckels on Unsplash

Hello everyone! I have now started writing articles related to some Data Structures and Algorithms, and I would be doing it topic wise. I have chosen to begin with Graphs since it is an important topic. This article will not be the only one in Graph related problems. I will be writing some more articles attributed to Graph coding problems, and this one is the first of them.

In the complete Graph series, I aim to cover all the significant algorithms related to graph coding problems which are:-

  1. Breadth-First Search (BFS)
  2. Depth-First Search (DFS)
  3. Disjoint Set — Union Find
  4. Dijkstra’s Algorithm

So, in the first part, we would deal with all the Island counting related problems. I will be linking the problems with their Leetcode pages so that you can go and practice them there.

I will explain the problem and the solution approach and would also provide working code in C++ language.

1. Number of Islands

Problem Statement

--

--

Kumar Shubham
CodeX
Writer for

SDE @ Wells Fargo | Ex-SWE Intern @ ByteLearn | Student @ IIT BHU | Web Dev | DSA | https://www.linkedin.com/in/shubham1710