# Find Multiple Shapes

the image has random shapes filled with 0s, separated by 1s. Find all the shapes. **Each shape is represented by coordinates of all the elements inside.**

Similar as LC 200

```
public class Main {
    public List<List<Integer>> findMultipleShapes(int[][] board)
    {
        List<List<Integer>> result = new ArrayList<>();
        for(int i = 0; i< board.length; i++)
        {
            for(int j = 0; j< board[0].length; j++)
            {
                if(board[i][j] == 0)
                {
                    List<Integer> shape = new ArrayList<Integer>();
                    dfs(board, i, j, shape);
                    result.add(shape);
                }
            }
        }
        return result;
    }

    public void dfs(int[][] board, int x, int y, List<Integer> shape)
    {
        if(!isBound(board, x, y))
        {
            return;
        }
        if(board[x][y] == 1)
        {
            return;
        }
        shape.add(x);
        shape.add(y);
        board[x][y] = 1;

        dfs(board, x-1, y, shape);
        dfs(board, x+1, y, shape);
        dfs(board, x, y-1, shape);
        dfs(board, x, y+1, shape);
    }

    public boolean isBound(int[][] board, int x, int y)
    {
        return x>=0 && x<board.length && y>=0 && y<board[0].length;
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://junnie.gitbook.io/wayfair/oa/karat/find-multiple-shapes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
