© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
2 replies
morry329#

✅ why is it '1' instead of '0'??

So I am analysing this solution https://leetcode.com/problems/number-of-islands/solutions/3585795/c-flood-fill-solution-beats-90-easy-to-understand-clean/?envType=study-plan&envId=level-1&plan=leetcode-75

Just one block of code puts me off very much:
if(grid[x][y] == '1'){
            grid[x][y] = '0';
        }
if(grid[x][y] == '1'){
            grid[x][y] = '0';
        }
`

Why is the code like this, if the grid is painted '1' then the grid turns '0'? I tried to play around with this block for understanding it (swap '0' and '1' or set both of the chars to '1' '1' etc), my try led to stack overflow.
LeetCode
C#| Flood fill solution, beats 90%, Easy to understand, clean. - Nu...
View shayke223's solution of Number of Islands on LeetCode, the world's largest programming community.
C#| Flood fill solution, beats 90%, Easy to understand, clean. - Nu...
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ ✅ why properties instead of public fields
C#CC# / help
3y ago
Needing help on why it always does 60 instead of 120.
C#CC# / help
2y ago
Why does Task 1 prints first instead of Task 3 - Async & Await
C#CC# / help
2y ago
Why use `await AbcAsync()` instead of `Abc()`
C#CC# / help
9mo ago