Skip to content
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

Ports - Faiza #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Ports - Faiza #17

wants to merge 2 commits into from

Conversation

Faiza1987
Copy link

No description provided.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

This is a solid brute-force solution. However you could get it down to an O(n + m) time complexity using a hash. I encourage you to give it a try.

@@ -1,6 +1,23 @@
# Returns a new array to that contains elements in the intersection of the two input arrays
# Time complexity: ?
# Space complexity: ?
# Time complexity: O(n^2) because there are nested loops and n is the length of the input array

Choose a reason for hiding this comment

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

The two arrays are not guaranteed to be of the same length. This is more accurate to be O(n + m) where n and m are the lengths of the respective arrays.

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