LeetCode 695 Max Area of Island - Google Coding Interview Question. DFS Java Solution Explained

preview_player
Показать описание
LeetCode 695 Max Area of Island
Lintcode 1080 Max Area of Island

Google Coding Interview Question

If you find this video helpful, please 'Like' or 'Subscribe'.
This is really helpful for the channel and also motivates me to do more of such good videos.

DFS Java Solution Explained In Detail With Example. Step by step explanation how to solve this problem.

We will keep finding areas of islands in the given grid and keeping track of the maximum area we found so far.

Coders, for your information:
If the island connection condition is changed from only vertically and horizontally connected to
"vertically and horizontally and diagonally connected", we will have to do the DFS in 8 directions instead of 4 directions. In that case diagonally connected islands may be with bigger areas.

Time Complexity:
O(R*C), where R is the number of rows in the given matrix, and C is the number of columns.
We visit every cell of the matrix once.

Space complexity: O(R*C)

Link To The Problem:

#coding #softwareengineer #Leetcode #Algorithm #DataStructure #Java #programmer #tech #software #codinglife #Preparation
#interview #programminglife #programmingisfun #dfs #leetcode #leetcode695 #codeforces #algorithm #algorithms #datastructure #datastructuresandalgorithms
Рекомендации по теме