Getting segmentaion fault in, famous number of islands question help plzz

question:-
Given a grid consisting of '0’s(Water) and '1’s(Land). Find the number of islands.
Note: An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically or diagonally i.e., in all 8 directions.
Input:
grid = {{0,1},{1,0},{1,1},{1,0}} **
Output:** 1 **
Explanation:** The grid is- 0 1 1 0 1 1 1 0 All lands are connected.

I was wondering how @cubefreak777 had lost 3* for a moment, there XD

4 Likes

Seriously, I checked my contest history to see if I screwed some rated contest XD…

3 Likes

Hahaha… Saw you a few days back at Cladding the Code contest and as usual, just stalked you a bit and loved this avatar.

1 Like

in question they have mentioned all 8 directions

yeah bro got it

1 Like

thank you

1 Like

even I thought same :rofl:

1 Like

bro it is wrong answer as 2

@ssrivastava990 I think I should change it… I am creating confusion in the community. XD

@karthik_k7 I read the problem statement, yes it requires the diagonal calls also. sorry, my bad. I thought neighbours are up, down, left and right only.
ps: removing the other solution

Correct approach :