Hey folks,
Let’s discuss anything related to the NUMBER OF ISLANDS problem in this thread.

@gouravsardana @peruljain
my edge case 3 is failing…any hints?

done, didn’t thought about it

Any idea anyone? Your help will be appreciated. Even for me only this is failing.

Solved. Right didn’t think of it.

1 Like

Same here, please help

test for case n==0 and return accordingly

1 Like

all my base cases are failing while all the edge cases and sample cases are passing.

python3 runner.py --problem NumberOfIslands --lang java --submitsample-input-1.txt : Passed
sample-input-2.txt : Passed
Traceback (most recent call last):
File “runner.py”, line 226, in
commit(args.problem, args.lang, True)
File “runner.py”, line 132, in commit
File “/usr/local/lib/python3.6/dist-packages/git/remote.py”, line 846, in push
return self._get_push_info(proc, progress)
File “/usr/local/lib/python3.6/dist-packages/git/remote.py”, line 732, in _get_push_info
File “/usr/local/lib/python3.6/dist-packages/git/cmd.py”, line 408, in wait
raise GitCommandError(self.args, status, errstr)
git.exc.GitCommandError: Cmd(‘git’) failed due to: exit code(1)
cmdline: git push --porcelain origin
stderr: ‘error: remote unpack failed: index-pack abnormal exit
error: failed to push some refs to ‘git@gitlab.crio.do:COHORT_ME_PS_DS1_ENROLL_2020_PROD/{user-name}.git’’

This is the error I am getting
How to resolve this?

1 Like

Any hint on edge case 3 plz?

I did not understand problem statement. Here is what I understood

  1. There is 0’s all around given matrix.
  2. Count the number of 1’s that has minimum three 0’s in the four direction(Up,Down,Left or Right).

If I am wrong Can you explain this line to me
"is formed by connecting adjacent lands horizontally or vertically"
My Question: Minimum number of directions in which water should be present around a land for calling it a Island.

I understood it now We have to collect group of 1’s in the matrix vertically or horizontally connected and then return number of Island that are not connected to each other.

1 Like

It means that if a piece of land i.e a group of 1 connected together is surrounded by water(0) from all the directions( left, right, up, down) , then it can be called an island.

edge case 2 is failling!!. any idea??

Hint for edge test cases: Does your code handle all non-negative inputs? Does you code handle an all 0 or all 1 matrix?

1 Like

Hey even I am struck there did you solve it

Failing only at edge case -2

solved it no issues tried to figured it out

I have the same problem, any ideas??

Need some kind of hint am stuck for a bit

Hint: Does you code handle case where there is one big island or no islands at all?