-
Notifications
You must be signed in to change notification settings - Fork 40
Shubha 👽 #21
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?
Shubha 👽 #21
Conversation
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.
Thanks for getting this in. Nice work, you hit all the learning goals here. Well done!
# Time Complexity: O(n * m log m) where m is the number of strings, and m is the length of a string | ||
# Space Complexity: O(n * m) where n is the number of strings, and m is the length of a string (m space complexity from sort) |
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.
👍
# Time Complexity: ? | ||
# Space Complexity: ? | ||
# Time Complexity: O(n * k), where n is the length of the list and k is the number of common elements to return | ||
# Space Complexity: O(n + k) where n is the length of the list and k is the number of common elements to return |
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.
Since you're building a hash of unique elements I would say that dominates the time complexity.
So O(m) where m is the number of unique elements.
counts = Hash.new(0) | ||
(row_start...row_end).each do |row_index| | ||
(col_start...col_end).each do |col_index| | ||
char = table[row_index][col_index] | ||
if char.to_i.to_s == char | ||
counts[char] += 1 | ||
return false if counts[char] > 1 | ||
end | ||
end | ||
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.
Nice, although you might be able to reduce the complexity of this loop a bit by creating a method.
Hash Table Practice
Congratulations! You're submitting your assignment!
Comprehension Questions