-
Notifications
You must be signed in to change notification settings - Fork 0
Lesson7 #8
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: lesson7
Are you sure you want to change the base?
Conversation
Dzhoker1
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.
Оставил комментарии по коду
| hashesarray = [] | ||
| for i in range(0, len(s)): | ||
| for j in range(0, len(s)): | ||
| if hash(s[i:j + 1]) not in hashesarray: |
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.
Каждая проверка наличия хэша в списке имеет сложность O(n), отсюда и такой разрыв во времени выполнения.
| def mod_count_substrings(s): | ||
| d = collections.OrderedDict() | ||
| for i in range(0, len(s)): | ||
| for j in range(0, len(s)): |
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.
Второй цикл можно начинать не от 0, а от j.
|
|
||
| # Проверяем работу функции | ||
| print(count_substrings('mama')) | ||
| print(count_substrings('mama')) |
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.
Отличное решение
No description provided.