-
Notifications
You must be signed in to change notification settings - Fork 47
quin - time #29
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
base: master
Are you sure you want to change the base?
quin - time #29
Conversation
CheezItMan
left a comment
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.
Good work, you hit most of all the learning goals here. Well done.
Take a look at my comments and let me know if you have any questions.
| @@ -1,3 +1,13 @@ | |||
| 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.
This works, but it's O(n * m) in time complexity. Using a hash you can get this to O(n + m) time complexity which is much better.
I encourage you to think about how to do this.
| @@ -1,4 +1,18 @@ | |||
|
|
|||
| def palindrome_permutation?(string) | |||
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.
👍 This works
| string2 = string2.split("") | ||
| hash = {} | ||
| string1.each do |char| | ||
| hash[char] = true |
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 would do better to count the number of times each letter appears.
| @@ -1,4 +1,21 @@ | |||
|
|
|||
| def permutations?(string1, string2) | |||
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.
This doesn't quite work, for example it would fail for heelo and hello. See my note below.
No description provided.