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

Time - Emily #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Time - Emily #43

wants to merge 1 commit into from

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