Number of islands


whats wrong with my bfs approach

@i_am_dekard_shaw
Your logic is correct but there is slight mistake in taking input. See for each row input integer is not separated by space. It is a string of ‘1’ and '0’s. So write string num; cin>>num; after line 50 and change cin>>a[i][j]; to a[i][j]=num[j]-‘0’;
your code will work fine for all cases.

@i_am_dekard_shaw
Here is the updated code. plz check