Skip to content

Conversation

@Hunter315
Copy link

self.left.depth_first_for_each(cb)
if self.right != None:
self.right.depth_first_for_each(cb)
return
Copy link

Choose a reason for hiding this comment

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

✔️

# if name_1 == name_2:
# duplicates.append(name_1)
a_set = set(names_1)
b_set = set(names_2)
Copy link

Choose a reason for hiding this comment

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

nice you can also use intersection or a for loop with an if all of these would be O(n)

O(n)

5. What is the runtime complexity of the provided code in `names.py`?
O(n^2) since it is looping through each element of each list to compare to each element of the other
Copy link

Choose a reason for hiding this comment

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

✔️

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