-
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
Pine - Alma #26
base: master
Are you sure you want to change the base?
Pine - Alma #26
Conversation
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.
🐶🐾 Nice work, Alma. Overall it looks like a solid BFS implementation, I just left a few comments and suggestions. Let me know what questions you have.
🟢
Time Complexity: O(V + E) | ||
Space Complexity: O(n) |
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.
✨ Correct for a breadth first search implementation, but I would suggest you define your variables particularly because you use different variables to represent the same thing here. V and n both represent the number of vertices/nodes and E represents the number of edges.
for i in range(len(dislikes)): | ||
if dislikes[i]: | ||
first_dog = i | ||
break | ||
if first_dog == None: | ||
return True |
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.
Could you refactor this to avoid a break statement? Perhaps use a while
loop?
groups[first_dog] = first_group | ||
groups[first_dog] = True |
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.
Line 27 overwrites line 26 here.
No description provided.