Open
Conversation
khuddleup
commented
Jul 22, 2022
|
|
||
| # 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: |
Author
There was a problem hiding this comment.
^^^ 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.
kyra-patton
reviewed
Jul 25, 2022
kyra-patton
left a comment
There was a problem hiding this comment.
🐾🐶 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.
✨ 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) |
There was a problem hiding this comment.
Creative way to handle disconnected nodes in the graph!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.