Skip to content

Sheffield | 25-SDC-Nov | Hassan Osman | Sprint 2 | Improve code with precomputing#135

Open
HassanOHOsman wants to merge 8 commits intoCodeYourFuture:mainfrom
HassanOHOsman:feature/improve-code-with-precomputing
Open

Sheffield | 25-SDC-Nov | Hassan Osman | Sprint 2 | Improve code with precomputing#135
HassanOHOsman wants to merge 8 commits intoCodeYourFuture:mainfrom
HassanOHOsman:feature/improve-code-with-precomputing

Conversation

@HassanOHOsman
Copy link

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

In this pull request, I introduced pre-computation in order to speed up the implementations in "common_prefix" and "count_letters" directories.

@HassanOHOsman HassanOHOsman added Complete Volunteer to add when work is complete and all review comments have been addressed. Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 📅 Sprint 2 Assigned during Sprint 2 of this module and removed Complete Volunteer to add when work is complete and all review comments have been addressed. labels Feb 28, 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?

for i in range(len(strings) - 1):
common = find_common_prefix(strings[i], strings[i + 1])
if len(common) > len(longest):
longest = common
Copy link

Choose a reason for hiding this comment

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

Indentation on line 15 is a bit off.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed. Thank you!

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

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

Just did.

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.

Analysis looks good.

mentation compares each string with every single while looping through
nested for loop.
As a result, the compelxity time drops from the original O(n^2 * m) to
around O(n log n * m).
Copy link

Choose a reason for hiding this comment

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

n log n * m could be easily misinterpreted as n log (n * m). You probably mean m * n log n.

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

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants