Skip to content

Conversation

@deliaioanac
Copy link
Collaborator

This solution is based on the concept described here:
https://en.wikipedia.org/wiki/Disjoint-set_data_structure
In this solution, a subset is initially just a patch of land and their union (or one patch of land by itself) is an island.

This solution is based on the concept described here:
https://en.wikipedia.org/wiki/Disjoint-set_data_structure
In this solution, a subset is initially just a patch of land and their union (or one patch of land by itself) is an island.
@deliaioanac deliaioanac requested a review from kulizhsy July 9, 2018 22:37
Copy link
Collaborator

@kulizhsy kulizhsy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job and on such a short notice!

if (j > 0 && map[i][j - 1] &&
(i == 0 || !map[i - 1][j] ||
find((i - 1) * map.size() + j, parent) !=
find(i * map.size() + (j - 1), parent))) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if statement is very hard to parse mentally. Prefer to hide 'ugly' code like that behind helper functions:

if (j > 0 && map[i][j - 1] && AnotherCheck(...)) { ..}

Whoever needs to read this in 5 months time will thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants