-
Notifications
You must be signed in to change notification settings - Fork 65
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
base: master
Are you sure you want to change the base?
Kayla - Pine #38
Conversation
|
||
# 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: |
There was a problem hiding this comment.
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.
There was a problem hiding this 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 |
There was a problem hiding this comment.
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!
if not dislikes[current]: | ||
queue.append(current + 1) |
There was a problem hiding this comment.
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!
No description provided.