Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update DFS to use set #11

Merged
merged 3 commits into from
Mar 27, 2024
Merged

Update DFS to use set #11

merged 3 commits into from
Mar 27, 2024

Conversation

Takashiidobe
Copy link
Contributor

@Takashiidobe Takashiidobe commented Mar 27, 2024

Changing visited from a list to a set changes the n not in visited line to O(1) time instead of O(n), because it replaces a linear scan (in the case of a list) to a hash lookup (in the case of a set) which is O(1) time.

ref: #9

@msambol msambol changed the title dfs changes Update DFS to use set Mar 27, 2024
@@ -11,11 +11,12 @@
}



Copy link
Owner

Choose a reason for hiding this comment

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

can you remove this newline?

Copy link
Owner

@msambol msambol left a comment

Choose a reason for hiding this comment

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

A few small nits but looks great. Thank you!

Copy link
Owner

@msambol msambol left a comment

Choose a reason for hiding this comment

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

Thanks, @Takashiidobe!

@msambol msambol merged commit 9a2e61d into msambol:master Mar 27, 2024
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.

None yet

2 participants