-
-
Notifications
You must be signed in to change notification settings - Fork 14
London | 25-SDC-July | Andrei Filippov | Sprint 2 | Improve code with precomputing #31
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: main
Are you sure you want to change the base?
Conversation
OracPrime
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.
Common Prefix is good, counting letters needs a little attention
| return letter == letter.upper() | ||
| only_upper = 0 | ||
| only_uniq = set(s) | ||
| only_uniq_sorted = sorted(only_uniq) |
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.
Why do we need a sort here?
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.
Probably it's unnecessary here
| uppercase = [ch for ch in only_uniq_sorted if ch.isupper()] | ||
| lowercase = [ch for ch in only_uniq_sorted if ch.islower()] | ||
| for i in uppercase: | ||
| if i.lower() not in lowercase: |
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.
Because lowercase is a list, this is potentially slow. What else could you use?
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.
I can use sets here, because look up in a set is O(1) on average, while checking in a list is O(n).
…unnecessary sorting
Learners, PR Template
Self checklist
Changelist
Improved code with precomputing
Questions
no questions