Skip to content

Conversation

@snowistaken
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.

Overall nice work, you hit the learning goals here. I'm glad you could get this in. These types of questions are very common in interviews. Take a look at my inline comments and let me know what questions you have. Mostly my comments involve simplifying code.

@@ -1,3 +1,20 @@
def intersection(list1, list2)

Choose a reason for hiding this comment

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

👍

Comment on lines +16 to +20
if duplicate_letters.values.sum == string_array.length || duplicate_letters.values.sum == string_array.length - 1
return true
else
return false
end

Choose a reason for hiding this comment

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

You can simplify this and eliminate the if statement, since you're looking for a true/false answer.

Suggested change
if duplicate_letters.values.sum == string_array.length || duplicate_letters.values.sum == string_array.length - 1
return true
else
return false
end
return duplicate_letters.values.sum == string_array.length || duplicate_letters.values.sum == string_array.length - 1

Comment on lines +16 to +18
if intersections[value]
intersections[value] += 1
end

Choose a reason for hiding this comment

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

What if the value isn't in intersections? Why not return false, if it's not there.

I would also suggest subtracting instead of adding, and then you can check to see if all the values are 0.

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