Skip to content

C16 - Pine - Ainur#44

Open
adjayanbaeva wants to merge 2 commits intoAda-C16:masterfrom
adjayanbaeva:master
Open

C16 - Pine - Ainur#44
adjayanbaeva wants to merge 2 commits intoAda-C16:masterfrom
adjayanbaeva:master

Conversation

@adjayanbaeva
Copy link

No description provided.

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.

🐾🐶 Good work, Ainur. I wrote a comment to help point you in the right direction as to why your test cases aren't passing. Let me know what questions you have.

🟡

Time Complexity: ?
Space Complexity: ?
Time Complexity: O(N+E) N-number of nodes, E -number of edges
Space Complexity: O(N)??

Choose a reason for hiding this comment

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

🪐 Yes! Space complexity will be O(N) because the data structures you create, queue, visited, group1, and group2 can each hold at most N nodes (aka dogs).

into the same partition.
Time Complexity: ?
Space Complexity: ?
Time Complexity: O(N+E) N-number of nodes, E -number of edges

Choose a reason for hiding this comment

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

group1 = set()
group2 = set()

queue.append(0)

Choose a reason for hiding this comment

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

Your two test cases are failing because you need a guard clause to find the first node in the list that is connected to other nodes in the graph.

Say you have a graph such as this:
dislikes = [ [], [2, 3], [1, 3], [1, 2] ]
If you draw out the graph, you will see that Node 0 is disconnected from the rest of the graph - it has no edges. Because it has no edges/neighbors, nothing else will be added to your queue after you pop Node 0 off the queue and you will return True by default.

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