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

Sockets - Karla #16

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

Sockets - Karla #16

wants to merge 2 commits into from

Conversation

kguadron
Copy link

No description provided.

@@ -1,6 +1,28 @@
# Returns a new array to that contains elements in the intersection of the two input arrays
# Time complexity: ?
# Space complexity: ?
# Time complexity: O(n + m) where n and m are the lengths of the two array inputs

Choose a reason for hiding this comment

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

Will both arrays always be equal in length?

elsif array1.length < array2.length
larger = array2
smaller = array1
elsif array1.length >= array2.length

Choose a reason for hiding this comment

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

I notice you used >= but not <= on line 8 for comparison. What's your thinking behind this choice?


hash_table = {}
smaller.each do |num|
hash_table[num] = 1

Choose a reason for hiding this comment

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

What happens if two keys are the same?

combined = []
larger.each do |num|
if hash_table.include? num
combined << num

Choose a reason for hiding this comment

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

I'm not sure if anything is being combined here. Perhaps matches might be a better variable name.

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