-
Notifications
You must be signed in to change notification settings - Fork 47
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
base: master
Are you sure you want to change the base?
Time - Emily #43
Conversation
…le palindrome methods.
There was a problem hiding this 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
if duplicate_letters.values.sum == string_array.length || duplicate_letters.values.sum == string_array.length - 1 | ||
return true | ||
else | ||
return false | ||
end |
There was a problem hiding this comment.
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.
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 |
if intersections[value] | ||
intersections[value] += 1 | ||
end |
There was a problem hiding this comment.
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.
No description provided.