LinkedInSoftware Engineer · Take-home ProjectCodemia practiceFind connected components in grid
Given a 2D grid consisting of 0s and 1s, where 1s represent land and 0s represent water, write a function to find all connected components of land in the grid. A connected component is defined as a group of adjacent 1s that are connected horizontally or vertically. The function should return a list of lists, where each inner list contains the coordinates of the cells that make up a connected component.