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
The reason will be displayed to describe this comment to others. Learn more.
Code looks good.
Can 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
Mar 2, 2026
For " find_longest_common_prefix" :
The previous implementation compared the common prefix of every pair of strings, resulting in a time complexity of O(n² × m). The new implementation sorts the strings first and only compares adjacent strings, reducing the time complexity to O(n log n + n × m).
And
For " count_letters" :
The previous implementation searched the string for each uppercase letter, resulting in a time complexity of O(n²). The new implementation uses sets for faster lookups, reducing the time complexity to O(n).
Sorting strings involve comparing strings character by character. If we take into account, $m$, the average length of the strings in the given array, then the time complexity of sorting would also affected by $m$.
cjyuan
removed
the
Needs Review
Trainee to add when requesting review. PRs without this label will not be reviewed.
label
Jul 7, 2026
Thanks @cjyuan, Yes, you are right. i missed the cost of string comparison during sorting.
ِThe overal complexity is :O(n log n × m + n × m)
simplifies to : O(n log n × m)
This part is a bit complicated for me. Please let me know if I need to change anything.
cjyuan
added
Complete
Volunteer to add when work is complete and all review comments have been addressed.
and removed
Needs Review
Trainee to add when requesting review. PRs without this label will not be reviewed.
Reviewed
Volunteer to add when completing a review with trainee action still to take.
labels
Jul 20, 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.📅 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.
Self checklist
Changelist
Introduced precomputing to reduce repeated work and improve performance of common_prefix and count_letters functions.