Amazon Onsite question - SDE 1

Anonymous User
791
Mar 15, 2025
Mar 15, 2025

Recently got this in an Amazon onsite interview, I have solved the question using BFS but the interviewer seems to give mixed reaction to my solution. Though he didn't mention if it was wrong or right

Can anyone give me the solution or approach for this, want to check if there are any other methods to solve this

Problem: Given a matrix consisting of 0s and 1s, count the number of islands (Number of Islands - LC 200).
Follow-up: If there is a gap of only one cell between two islands, they should be considered connected.
Constraints : No extra space allowed.

Comments (4)