PR to add some hash problems#387
Merged
Merged
Conversation
| map = {} | ||
| for i in range(len(s)): | ||
| if s[i] not in map: | ||
| if t[i] in map.values(): |
Collaborator
There was a problem hiding this comment.
We can make this O(n) from O(n^2), if we store the map.values() in a seperate set.
| """ | ||
| if len(s) != len(t): | ||
| return False | ||
| map = {} |
Collaborator
There was a problem hiding this comment.
map overshadows built-in map in Python.
Collaborator
Author
There was a problem hiding this comment.
You mean changing the name?
| return False | ||
| for i in range(len(pattern)): | ||
| if pattern[i] not in map: | ||
| if list_str[i] in map.values(): |
Collaborator
There was a problem hiding this comment.
Similar optimization can be used here too!
| :rtype: List[str] | ||
| """ | ||
| keyboard = [ | ||
| set(list('qwertyuiop')), |
Collaborator
There was a problem hiding this comment.
I think set('qwertyuiop') will be fine. No need for list.
Owner
There was a problem hiding this comment.
>>> set('acvvvv')
set(['a', 'c', 'v'])
yep
Collaborator
Author
There was a problem hiding this comment.
Okay, I will fix now
Collaborator
Author
|
@goswami-rahul @keon I have updated! |
Pull Request Test Coverage Report for Build 715
💛 - Coveralls |
goswami-rahul
approved these changes
Aug 14, 2018
Owner
|
nice work :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(Put an
Xinside the[ ]to denote check mark[X].)If creating a new file :
if done some changes :
other