mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2026-05-02 06:21:20 +08:00
761 B
761 B
id, title, topics, difficulty, source
| id | title | topics | difficulty | source | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 2 | Matrix Islands |
|
easy |
|
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