You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I originally completed all the Sprint 2 exercises in one PR, but the validation expected separate PRs for each issue. This PR contains only the "Improve code with precomputing" exercise.
Improved performance by introducing precomputing techniques in:
The reason will be displayed to describe this comment to others. Learn more.
Code are correct.
Could you use complexity to explain how the new implementation is better than the original implementation?
cjyuan
added
Reviewed
Volunteer to add when completing a review with trainee action still to take.
and removed
Needs Review
Trainee to add when requesting review. PRs without this label will not be reviewed.
labels
Jul 9, 2026
Could you use complexity to explain how the new implementation is better than the original implementation?
Sure,
For common_prefix, the original solution compared every pair of strings, resulting in O(n²) complexity. By sorting the strings first (O(n log n)) and then comparing only neighbouring strings, the overall complexity is reduced to O(n log n).
For count_letters, the original solution checked membership in the string for every character, resulting in O(n²) complexity. The refactored version pre-computes a set of characters in O(n), allowing O(1) lookups and reducing the overall complexity to O(n).
cjyuan
added
Complete
Volunteer to add when work is complete and all review comments have been addressed.
and removed
Reviewed
Volunteer to add when completing a review with trainee action still to take.
labels
Jul 14, 2026
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
CompleteVolunteer to add when work is complete and all review comments have been addressed.Module-ComplexityThe name of the module.📅 Sprint 2Assigned during Sprint 2 of this module
2 participants
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.
I originally completed all the Sprint 2 exercises in one PR, but the validation expected separate PRs for each issue. This PR contains only the "Improve code with precomputing" exercise.
Improved performance by introducing precomputing techniques in:
All provided tests pass.