Skip to content

London | SDC Nov 25 | Emiliano Uruena | Sprint 2 |Improve with precomputing#142

Open
Emilianouz wants to merge 2 commits intoCodeYourFuture:mainfrom
Emilianouz:Sprint2-ImproveWithPrecomputing
Open

London | SDC Nov 25 | Emiliano Uruena | Sprint 2 |Improve with precomputing#142
Emilianouz wants to merge 2 commits intoCodeYourFuture:mainfrom
Emilianouz:Sprint2-ImproveWithPrecomputing

Conversation

@Emilianouz
Copy link

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

Refactor common_prefix and count_letter functions with precomputing.

@Emilianouz Emilianouz added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 1, 2026
Copy link

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use complexity to explain how the new implementation are better than the original implementation?

@cjyuan 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
using sorted(strings) to prevent the side effect.
@Emilianouz Emilianouz added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 2, 2026
@cjyuan
Copy link

cjyuan commented Mar 2, 2026

Can you also address this comment: #142 (review)

@cjyuan 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
@Emilianouz
Copy link
Author

Can you use complexity to explain how the new implementation are better than the original implementation?

@cjyuan The original had complexity O(n² × m) because compares every possible pair of strings, and each comparison can take up to O(string length). The improved version first sorts the list in O(n log n) then only compares neighbours strings O(n × m). That reduces the number of comparisons.

@Emilianouz Emilianouz added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 3, 2026
@cjyuan
Copy link

cjyuan commented Mar 3, 2026

If we are factoring in the length of the strings, m, then the complexity of sorting won't just be O(nlogn). nlogn measures only the number of comparisons needed.

@cjyuan 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 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants