You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tech-interview-handbook/questions/02-matrix-islands.md

57 lines
761 B

---
id: 2
title: Matrix Islands
topics: [array, depth-first-search, matrix]
difficulty: easy
source:
- https://leetcode.com/problems/number-of-islands/
- https://leetcode.com/problems/max-area-of-island/
- https://leetcode.com/problems/number-of-distinct-islands/
---
## Question
```
'''
Given a matrix of 0s and 1s, count the number of islands present.
[[0,0,1],
[0,0,0],
[0,1,1]]
Answer: 2
'''
```
## Follow Up
```
Given a matrix of 0s and 1s, find the size of the largest island present.
'''
[[0,0,1],
[0,0,0],
[0,1,1]]
Answer: 2
```
## Follow Up II
```
Given a matrix of 0s and 1s, find the number of unique islands present present.
'''
[[1,0,1,0],
[1,0,0,0],
[0,1,1,0]]
Answer: 3
[[1,1,0,1],
[0,0,0,0],
[0,1,1,0]]
Answer: 2
```