This visualization will help you count number of element group in a grid.
Black Shape on InterviewBit
Number of Islands on LeetCode
Do you think this helps you? Please consider to my repo to let me know!