Distinct Island

Given a boolean 2D matrix. The task is to find the number of distinct islands where a group of connected 1s (horizontally or vertically) forms an island. Two islands are considered to be distinct if and only if one island is identical to another (not rotated or reflected).

CodingNinjas
author
2y
  • Firstly I told the interviewer, the Depth-first search approach. I ran Depth-first search on each element of the matrix which is un-visited while traversing the matrix and for each island, I assigned ...read more
CodingNinjas
author
2y
Depth First Search
  • For every 1 in the matrix, do DFS and mark all the 1’s as visited which are connected to this 1 and store the path of the island in a string.

Followings are the abbreviated path :

‘...read more

Help your peers!
Add answer anonymously...
Barclays Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter