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

Kayla - Pine #38

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Kayla - Pine #38

wants to merge 4 commits into from

Conversation

khuddleup
Copy link

No description provided.


# Additionally, if the next dog is NOT group 1, add the current dog to group 2
# But if the next dog is NOT in group 1 then add it to group 2
else:
Copy link
Author

Choose a reason for hiding this comment

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

^^^ This shold actually say, if the current dog IS in group 1, then check to see if the next dog is also in group 1, and if it it is return false, cuz aint no way these dogs will get along. But if the next dog is NOT in group 1, then add it to group 2.

Copy link

@kyra-patton kyra-patton left a comment

Choose a reason for hiding this comment

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

🐾🐶 Very nice BFS implementation, Kayla. Really appreciate you working through this! Let me know what questions you have.

🟢

Time Complexity: ?
Space Complexity: ?
Time Complexity: O(n+e) number of nodes in the graph and e is the numbner of edges
Space Complexity: O(n) storing 4 variables? Checked, G1, G2, queue. drop the constant

Choose a reason for hiding this comment

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

✨ Yes, because queue, checked, group1, and group2 each can hold at most n elements, where n is the number of nodes (or dogs) in dislikes. Nice work!

Comment on lines +31 to +32
if not dislikes[current]:
queue.append(current + 1)

Choose a reason for hiding this comment

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

Creative way to handle disconnected nodes in the graph!

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.

2 participants